Description
openedon Feb 14, 2020
This issue is about enabling following query
context.Orders.GroupBy(o => o.CustomerID).ToList();
This is NOT about client evaluating when there is any additional operator after GroupBy or result selector is specified in GroupBy.
Examples of disallowed queries where we will NOT client eval GroupBy operator
context.Orders.GroupBy(o => o.CustomerID).Select(g => new { g.Key, OrderDates = g.Select(e => e.OrderDate).ToList()).ToList();
context.Orders.GroupBy(o => o.CustomerID, (k, os) => new { OrderDates = os.Select(e => e.OrderDate).ToList()).ToList();
As of EF Core 3.1 certain constructs of GroupBy where GroupBy is composed over (followed by another queryable operator) is translated. Read our GroupBy operator documentation to understand what is supported scenarios.
There are few other cases, where GroupBy with composition can be translated to server but not yet translated. To list a few
- GroupBy-aggregate operator with another join (Query: Join after GroupByAggregate throws when join key uses grouping key or aggregate function #10012)
- Grouping-Where-Aggregate or Grouping-Select-Aggregate (Query: GroupBy Where Aggregate translation to server #11711/ Can't translate GroupBy with Conditional Aggregate #18836)
- Grouping-FirstOrDefault over the group (Translate GroupBy followed by FirstOrDefault over group #12088)
- Ability to select top N of each group (Support ability to select top N of each group #13805)
- Grouping-Distinct-Aggregate (Aggregate function distinct count throw InvalidOperationException #17376)
- GroupBy entity type (Support for GroupBy entityType #17653)
Resolution of this issue only enables client evaluation of GroupBy when it is last operator. Any of the above listed missing features will not work even if this issue is fixed. Please upvote relevant issue from above list which you need in your scenario. Please upvote this issue iff you need client side evaluation of GroupBy operator when it is last operator.