Skip to content

Commit

Permalink
Query: Throw better error message when final result contains IGrouping
Browse files Browse the repository at this point in the history
Part 1 of #26046
  • Loading branch information
smitpatel committed Sep 15, 2021
1 parent 8059b57 commit febaf58
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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

0 comments on commit febaf58

Please sign in to comment.