-
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
Using .Count
on a ICollection<T>
does not produce EXISTS
as it does when using List<T>
#35365
Comments
@cincuranet interested in giving this a look? |
@roji See
Changing that section to the following should do the trick
|
@ChrisJollyAU thanks for looking into it... Are you interested in submitting a PR? |
Sure. I haven't got a test sorted yet so will do that sometime |
@roji PR done. There were a bunch of other tests that were affected so those are changed. Do you still want a basic test for just this issue? |
@ChrisJollyAU if we have other changes that already ensure this won't regress, then no, I think it's fine to submit without an additional test. |
In the whats new in .net 9, it says that queries using
.Count
are now optimized to useEXISTS
instead ofCOUNT
. However, this seems to be true for collections of typeList<T>
. We useICollection<T>
in our projects and we would love to replace.Any()
with.Count > 0
but this optimization isn't applied as shown belowproduces:
Using
context.Blogs.Where(b => b.Posts.Count != 0);
will make it even worse:EF Core version: 9.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
The text was updated successfully, but these errors were encountered: