You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
QueryRewrite: add navigation expansion support for GroupBy #15249
This is complicated because navigations that appear in the grouping selector need to be expanded before the groupby call itself. This probably requires a number of "pending" operations to be stored on NavigationExpansionExpression, just like we do for projections and order by.
@smitpatel For queries like (in #14152 you mentioned that it's duplicate form this issue):
returnAssertQuery<Customer>(isAsync,
cs =>cs.GroupBy(c =>c.City).Select(
g =>new{g.Key,c=g.SelectMany(o=>o.Orders).Count()}),
e =>e.Key);
It still fails with:
System.InvalidOperationException : Processing of the LINQ expression 'AsQueryable<Order>(SelectMany<Customer, Order>(
source: NavigationTreeExpression
Value: default(IGrouping<string, Customer>)
Expression: (Unhandled parameter: e),
selector: (o) => o.Orders))' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core.
My guess it caused by g.SelectMany(o=>o.Orders).Count() really being g.SelectMany(o=>o.Orders).AsQueryable().Count() expression and as a result (firstArgument is NavigationExpansionExpression source) is false
That would be a separate issue. Due to complexity of identifying navigations after applying GroupBy, that is not implemented yet.
Work-around
returnAssertQuery<Customer>(isAsync,
cs =>cs.SelectMany(c =>c.Orders,(c,o)=>new{c.City,o}).GroupBy(c =>c.City).Select(
g =>new{g.Key,c=g.Count()}),
e =>e.Key);
Activity
smitpatel commentedon Jul 2, 2019
After nav expansion
Nav expansion moving aggregates inside joins make it hard to translate.
Query: Expand navigations in GroupBy case
Query: Expand navigations in GroupBy case
Query: Expand navigations in GroupBy case
kosinsky commentedon Aug 26, 2019
@smitpatel For queries like (in #14152 you mentioned that it's duplicate form this issue):
It still fails with:
My guess it caused by g.SelectMany(o=>o.Orders).Count() really being g.SelectMany(o=>o.Orders).AsQueryable().Count() expression and as a result (firstArgument is NavigationExpansionExpression source) is false
Should I create separate issue for that?
smitpatel commentedon Aug 26, 2019
That would be a separate issue. Due to complexity of identifying navigations after applying GroupBy, that is not implemented yet.
Work-around