Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private ShapedQueryExpression CreateShapedQueryExpression(SelectExpression selec
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());
projection = _sqlExpressionFactory.Function("AVG", new[] { projection }, projection.Type, projection.TypeMapping);
projection = _sqlExpressionFactory.Function("AVG", new[] { projection }, resultType, _typeMappingSource.FindMapping(resultType));

return AggregateResultShaper(source, projection, throwOnNullResult: true, resultType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,22 +699,19 @@ public override async Task Min_no_data_subquery(bool async)
AssertSql();
}

public override async Task Average_with_no_arg(bool async)
{
// Always throws for sync.
if (async)
{
// Average truncates. Issue #26378.
await Assert.ThrowsAsync<EqualException>(async () => await base.Average_with_no_arg(async));
public override Task Average_with_no_arg(bool async)
=> Fixture.NoSyncTest(
async, async a =>
{
await base.Average_with_no_arg(a);

AssertSql(
"""
AssertSql(
"""
SELECT VALUE AVG(c["OrderID"])
FROM root c
WHERE (c["$type"] = "Order")
""");
}
}
});

public override Task Average_with_binary_expression(bool async)
=> Fixture.NoSyncTest(
Expand All @@ -730,22 +727,19 @@ FROM root c
""");
});

public override async Task Average_with_arg(bool async)
{
// Always throws for sync.
if (async)
{
// Average truncates. Issue #26378.
await Assert.ThrowsAsync<EqualException>(async () => await base.Average_with_arg(async));
public override Task Average_with_arg(bool async)
=> Fixture.NoSyncTest(
async, async a =>
{
await base.Average_with_arg(a);

AssertSql(
"""
AssertSql(
"""
SELECT VALUE AVG(c["OrderID"])
FROM root c
WHERE (c["$type"] = "Order")
""");
}
}
});

public override Task Average_with_arg_expression(bool async)
=> Fixture.NoSyncTest(
Expand Down