-
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: Support GroupJoin when it is final query operator #19930
Comments
Don't waste your time with this useless enhancement. This definitely is NOT what I wanted. Client eval, seriously? If it wasn't clear after all these writings in the now closed issue, I want FULL SERVER support for this LINQ operator. And btw, it has nothing in common with |
Really last comment :-) (hopefully constructive) Here is quick and dirty EXTERNAL implementation of what I wanted:
When applied, it allows translation/processing (in 3.1.1) of all The question is, if I can do that externally, why can't you do something similar internally (using all the power of your expression processing helpers/experience) :-/ Cheers. |
I think this is a good enhancement because without it, the (general) EF Core 3.x advice to manually switch to client-side evaluation does exactly what has been often commented as worth avoiding in automatic client side evaluation, i.e. pulling a lot of data from the server unnecessarily. At least, in something like
where could you put (I hope this case would be handled.) It would be really good if this supports projection at least so that unneeded columns aren't pulled to the client as in:
I am still not sure if translating to a single correlated SQL query versus two queries to minimize data transfer would be most efficient, but I suppose the answer would very depending on the database. |
context.Customers
.Where(c => c.CustomerID < 100)
.Select(c => new {
c = c,
os = context.Orders.Where(o => c.CustomerID == o.CustomerID).ToList()
}) is equivalent query. LINQ is magical. |
Yes, it is. That's why the EF job is to convert/transform/treat the original as the manually written equivalent. SQL also has different valid query constructs ( P.S. Sorry for repeating/linking to it couple times, but see the
|
While in theory that's true, given that the amount of work we have is huge, we prioritize working on translations (and features in general) which don't have easy/simple workaround such as this one. If it's possible to rewrite your LINQ query so that it works - and is even simpler as in the case above - isn't that reasonable? |
@roji No, it isn't, because you want be to do something additional work which is not strongly necessary. Because my time is costly too. Just out of curiosity, why you spent your valuable time writing the (IMHO more complicated) Why don't you go further and remove the whole LINQ support and ask the end users to rewrite their queries using some "even simpler" but EF Core specific dialect for their queries? Finally, it's a shame the "modern" framework translating less LINQ patterns than its "obsolete" predecessor. Just FYI :) |
Once again, where we can, we add translations based on the implementation cost, on whether a different construct exists to express the same thing, and importantly, based on user feedback. This issue has received almost no votes or feedback from users, which is a main reason why we haven't prioritized it. |
That is nice, could it not be used as a |
Because the victims go to StackOverflow instead of here? |
@NetMage This is what I'm fighting for here. But they "see no value" :( |
We do have other issues with hundreds of votes - this one does not. Note that @smitpatel - who is a team member - is the one who opened this issue in the first place, so it's not true that we see no value. But at the risk of repeating myself, this issue has very little user requests, and there is another LINQ construct that produces the same result (one could even say that it's simpler). Therefore, since we have an enormous list of things to do and our resources are limited, this issue is in the backlog (not closed). |
@powermetal63 Theoretically, if one cares enough, an enhancement could be done by someone from the community. Unfortunately having a usable EF Core is not my primary job, but I am working on a C# extension method using this translation in my spare time. |
@roji From my point of view this is continuation of #17068, which was closed by @smitpatel with the following conclusion
And here are some related issues recently closed as duplicate of it - #13887, #14490, #20660 What I'm trying to argue from the beginning is that putting As you can see from my sample code, doing that is quite easy even with external code. You already put significant effort in 3.x to support just one variation - LINQ left join pattern using SelectMany on GroupJoin.DefaultIfEmpty, and even additional effort for porting (refactoring) it into this huge TryFlattenGroupJoinSelectMany method. But running my What I'm suggesting is replacing |
@powermetal63 What is |
@sungam3r Nothing special, a typical expression visitor based helper for finding
|
@powermetal63 Can you provide a sample of the transformation your |
There are other 3rd party libraries which integrate on top of EF Core and provide all those functionality. OData is one big consumer with EF Core which provides paging/sorting/filtering functionality in the way you mention above without users having to write whole query themselves. We work with them so the queries generated by them are translated correctly in EF Core. There also other extension on top of EF Core to provide more functionality from database side & also other 3rd party library which can be used to create queries. |
OUCH! I have LINQ queries with 'into' clauses all over my Legacy code. I have just tried to upgrade that old Entity Framework v5.0 to Entity Framework core and hit this issue almost immediately. Stop removing features that used to work! I am tired of all the products being released with breaking changes and products that provide no upgrade path to get from a prior version to a new version. I am leaning towards abandoning Entity Framework as the upgrade hassle is beginning to outweigh the benefits. We just upgraded 30-year old legacy code and the SQL statements just ported straight into the new app! That's a big plus for just staying with good old SQL. |
This issue is about enabling following query.
We will not client eval GroupJoin in any of following cases
os
in above query in any formAll above unsupported cases will still throw client evaluation exception even after this issue is fixed.
GroupJoin operator in query which is used to generated LeftJoin in SQL as described in our documentation is supported and will remains so. Even after that use case, if you still need EF Core to client eval GroupJoin operator with aforementioned constraints please upvote this issue. We are not looking to client eval any other GroupJoin which appears in the middle of the query.
The text was updated successfully, but these errors were encountered: