Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Throw better error message when final result contains IGrouping #26050

Merged
merged 1 commit into from
Sep 16, 2021
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 @@ -110,6 +110,13 @@ public NavigationExpandingExpressionVisitor(
public virtual Expression Expand(Expression query)
{
var result = Visit(query);

if (result is GroupByNavigationExpansionExpression)
{
// This indicates that GroupBy was not condensed out of grouping operator.
throw new InvalidOperationException(CoreStrings.TranslationFailed(query.Print()));
}

result = new PendingSelectorExpandingExpressionVisitor(this, _extensibilityHelper, applyIncludes: true).Visit(result);
result = Reduce(result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2750,6 +2750,34 @@ public virtual Task GroupBy_group_Where_Select_Distinct_aggregate(bool async)

#region GroupByWithoutAggregate

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupBy_as_final_operator(bool async)
{
return AssertTranslationFailed(() => AssertQuery(
async,
ss => ss.Set<Customer>().GroupBy(c => c.City)));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupBy_Where_with_grouping_result(bool async)
{
return AssertTranslationFailed(() => AssertQuery(
async,
ss => ss.Set<Customer>().GroupBy(c => c.City).Where(e => e.Key.StartsWith("s"))));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupBy_OrderBy_with_grouping_result(bool async)
{
return AssertTranslationFailed(() => AssertQuery(
async,
ss => ss.Set<Customer>().GroupBy(c => c.City).OrderBy(e => e.Key),
assertOrder: true));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupBy_SelectMany(bool async)
Expand Down