-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: Join after GroupByAggregate throws when join key uses grouping key or aggregate function #10012
Comments
[ConditionalFact]
public virtual void GroupBy_Aggregate_Join()
{
AssertQuery<Order, Customer>(
(os, cs) =>
from a in os.GroupBy(o => o.CustomerID)
.Where(g => g.Count() > 5)
.Select(g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) })
join c in cs on a.CustomerID equals c.CustomerID
join o in os on a.LastOrderID equals o.OrderID
select new { c, o });
}
Few issues here:
|
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when key/element/result selector is DTO instead of anonymous type Resolves #11176 - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 Part of #10012
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when key/element/result selector is DTO instead of anonymous type Resolves #11176 - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated) - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012 Part of #2341
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated) - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012 Part of #2341
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated) - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012 Part of #2341
This is with EF Core SqlServer 3.0.0. |
I upgraded to 3.1.0-preview3.19554.8 and the issue persists. |
@mattheiler - It happens since you are selecting navigation off the entity you are joining. Hence it won't work for now. |
So this scenario is a known issue? Alrighty. |
Same with EF 3.1 on a fairly simple query: hidegh/Meal-tracker@a85ac8e It's just EF core issue, same approach works within EF6.x and well, I'd bet it works on NHibernate (even older versions) too. |
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. |
Yes, regarding odata - it works fine with efcore 2.2, but breaks with efcore 3+. I'm not sure if it is the same bug as discussed in this issue since this issue was originally entered before 2.2 even came out and odata works fine with 2.2 - just not 3+. It would be nice if someone from the efcore team could take a look and at least classify and/or comment on the problem with odata. For an official (and useful) microsoft project, odata doesn't get much thought from the other teams - for months aspnetcore changes were preventing people using odata migrating to .net core 3+ - they finally fix those - only to find out efcore changes are breaking it now at least for people who need group by. |
@MolallaComm We plan to sync with the OData team to get a better understanding of some of the queries that are generated. |
Imho this issue should be handled with pressure and not being open for several years. Let's have an example. SELECT C.*, O.DATE
FROM CUSTOMER C
JOIN (
SELECT CUSTOMER_ID, MAX(DATE) DATE
FROM ORDERS
GROUP BY CUSTOMER_ID) O ON C.CUSTOMER_ID = O.CUSTOMER_ID
ORDER BY O.DATE DESC 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. |
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. |
something like
The text was updated successfully, but these errors were encountered: