efcore: Query: Join after GroupByAggregate throws when join key uses grouping key or aggregate function
something like
var query = context.Orders.GroupBy(o => o.CustomerID).Select(g => new { g.Key, Count = g.Count() })
.Join(context.Customers, o => o.Key, c => c.CustomerID, (o, c) => new {C = c, o.Count});
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (10 by maintainers)
Commits related to this issue
- Query: Improvements to Relational GroupBy translation for composition Part of #10012 — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Improvements to Relational GroupBy translation for composition Part of #10012 — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Improvements to Relational GroupBy translation for composition - Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated wh... — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Improvements to Relational GroupBy translation for composition - Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated wh... — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Improvements to Relational GroupBy translation for composition - Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated wh... — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Improvements to Relational GroupBy translation for composition - Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated wh... — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Improvements to Relational GroupBy translation for composition - Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated wh... — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Client eval when doing joins after GroupByAggregate Part of #10012 — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Client eval when doing joins after GroupByAggregate Part of #10012 — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Client eval when doing joins after GroupByAggregate Part of #10012 — committed to dotnet/efcore by smitpatel 6 years ago
- Query: Client eval when doing joins after GroupByAggregate Part of #10012 — committed to dotnet/efcore by smitpatel 6 years ago
- Add regression tests for issue#10012 Resolves #10012 — committed to dotnet/efcore by smitpatel 4 years ago
- Add regression tests for issue#10012 Resolves #10012 — committed to dotnet/efcore by smitpatel 4 years ago
- Add regression tests for issue#10012 (#21589) Resolves #10012 — committed to dotnet/efcore by smitpatel 4 years ago
All the queries described in this issue were already working. They may have started working in 3.1 or in earlier previews of 5.0.
@MolallaComm We plan to sync with the OData team to get a better understanding of some of the queries that are generated.
Just wondering if this issue is going to be addressed and when. At the moment, it is blocking us from upgrading from dotnet core 2.2 to 3.1 and I looking at the thread, I suspect others are in the same boat.
Imho this issue should be handled with pressure and not being open for several years. Let’s have an example. You have 1.000.000 customers. Every customer has some orders with a date. And now you need the 50 customers (paging) with the newest orders. In SQL thats something like (without TOP 50):
This I currently impossible with EF Core. Reading all 1.000.000 customers and select 50 of them is not a solution. The only solution I found is to write raw SQL.
This is with EF Core SqlServer 3.0.0.
@mattheiler - While this issue is not marked as fixed, many of this scenarios could already be working. We have done work to improve implementation to make such queries translate though we did not have time to go through various queries to find edge case bugs. You can try running your query on 3.0 (or even better 3.1 preview) and it may be working already. If it is not then there is always easy work-around as mentioned here https://github.com/aspnet/EntityFrameworkCore/issues/10012#issuecomment-372830495 which is to apply key/aggregate operation in custom projection before composing join. And that already works. We would love to know what queries are still not working in 3.x release so that we can fix them in future release.
@reservoir-dogs We hope to fix this issue in the 3.0 release, which will be later this year.