Using .Count
on a ICollection<T>
does not produce EXISTS
as it does when using List<T>
#35365
Labels
.Count
on a ICollection<T>
does not produce EXISTS
as it does when using List<T>
#35365
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: