-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
IncludeOptimized Multiple Levels #715
Comments
Hello @cangunaydin , The best way has changed over time as some way that was working in EF Core 2 are no longer working in EF Core 3 and so on. For example, another working way is the following LINQ: var list = context.Orders
.IncludeOptimized(x => x.Items.SelectMany(o=>o.OrderItemDetails))
.IncludeOptimized(x => x.Items.SelectMany(o=>o.OrderItemDetails).SelectMany(y=>y.Gifts)).ToList(); Is it the best way? Look pretty much similar as the code you provided. There is no "perfect" way, this is the same under the hood for our library. Everything depends on the EF Core version and what this version can support. Best Regards, Jon |
So the suggested migration here is to just change all instances of Is this a project level factor? It seems like if |
1. Description
Hello after i upgraded my project to .net 6.0 and ef core 6.0, i was facing issue on the includeoptimized so normally what we have written before was breaking. here is an example code that we use
and exception we are getting is
3. Fiddle or Project
i reproduce the issue in dotnetfiddle and did some experiments,
https://dotnetfiddle.net/22qD0x
as i see it, if you use SelectMany() then do the Select() the problem is gone and i can use IncludeOptimized()
.IncludeOptimized(o => o.OfferItems.SelectMany(oi => oi.OfferItemScreenTenants).Select(oist=>oist.ScreenTenant))
this query works instead.
so the question is what is the best way to use IncludeOptimized for multilevel objects? Is this a correct usage?
thanks for the assistance
The text was updated successfully, but these errors were encountered: