Repository navigation
Breaking change note on duplicated results in Include - #1803
Conversation
| ``` csharp | ||
| var baseQuery = db.Customers.Where(c => c.CustomerName == "John"); | ||
| var customers = baseQuery.ToList(); // Loads customers without any related entities | ||
| baseQuery.SelectMany(c => c.Addresses).Load(); // Loads only the addresses |
There was a problem hiding this comment.
This is not explicit loading.
There was a problem hiding this comment.
How is it not explicit loading:
You can also explicitly load a navigation property by executing a separate query that returns the related entities.
There was a problem hiding this comment.
Explicit load APIs are defined on NavigationEntry. This is not navigation entry. This is pure IQueryable. Load function here is whole lot different than explicit loading.
There was a problem hiding this comment.
OK, I guess it's terminological but the functional idea and outcome are the same: load related entities explicitly after loading the principal - that's even how our docs say it. Whether it's done on NavigationEntry or on the IQueryable doesn't seem very important (at least to users). But I don't care that much either way.
There was a problem hiding this comment.
Outcome are altogether different. Explicit load API builds query with where predicate on key and can load only 1 entity's navigation at a time. You cannot even load reference navigation for items in the collection with that. At best using explicit loading for collection include gives you N + 1 queries and not 2 queries.
smitpatel
left a comment
There was a problem hiding this comment.
Add note to breaking changes only. Remove changes to related data section. I will write that part. Breaking changes could refer to github issue in product repo directly.
Are you sure you want to spend your time writing this, is what I wrote insufficient? In any case it would have been better to change assignments in #1769 or communicate better to prevent the double work. |
|
#1769 was about adding breaking changes section only. If you are tracking both with it, you can assign it to me. What is written in related data has a lot of inaccuracy. I am already working on query docs currently so related data section will also get updated. |
Well it does have "We should add a section in the loading related data page with a code sample." but it's not important. I'll remove the related data section from this PR. |
|
Triage decision was about breaking change only. (At least that was my understanding). And related data section written is not correct. |
2e19906 to
e8b9209
Compare
|
Removed related data section. |
|
Might be worth linking to the comment with the workaround: dotnet/efcore#18022 (comment) |
|
|
||
| **Mitigations** | ||
|
|
||
| While technically this is not a breaking change, it could have a considerable effect on application performance when a single query contains a large number of `Include` operator on collection navigations. [See this comment](https://github.com/aspnet/EntityFrameworkCore/issues/18022#issuecomment-535102526) for more information and for rewriting queries in a more efficient way. |
There was a problem hiding this comment.
As pointed out by @AndriySvyryd - This comment is incorrect link.
Closes #1769