Description
openedon Oct 2, 2020
Please tell me if this is a duplicate, but:
I want to avoid the "Cartesian Explosion Problem", I noticed that EF Core 5.0 has now the option to enable "split queries".
However, I found out that it's not possible to use split queries when collections are projected:
var result = dbContext.Products.AsSplitQuery().Select(p => new BookDto
{
Name = p.Name,
Rates = p.Ratings.Select(r => new RatingDto { Rate = r.Rate }).ToList(),
}).ToList();
This would cause the following exception to be thrown:
"The query has been configured to use 'QuerySplittingBehavior.SplitQuery' and contains a collection in the 'Select' call, which could not be split into separate query. Please remove 'AsSplitQuery' if applied or add 'AsSingleQuery' to the query."
Why isn't this possible? It seems perfectly reasonable!
I'm not sure but I believe this used to work in EF Core 2.x
Will this be implemented? It is very much needed! Thank you!
Provider and version information:
EF Core version: 5.0.0 RC1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0