Skip to content

Breaking change note on duplicated results in Include - #1803

Merged
roji merged 1 commit into
masterfrom
CartesianExplosion
Oct 2, 2019
Merged

roji merged 1 commit into
masterfrom
CartesianExplosion

Conversation

@roji

@roji roji commented Oct 2, 2019

Copy link
Copy Markdown
Member

Closes #1769

``` 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not explicit loading.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it not explicit loading:

You can also explicitly load a navigation property by executing a separate query that returns the related entities.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 smitpatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@roji

roji commented Oct 2, 2019

Copy link
Copy Markdown
Member Author

Remove changes to related data section

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.

@smitpatel

Copy link
Copy Markdown
Contributor

#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.

@roji

roji commented Oct 2, 2019

Copy link
Copy Markdown
Member Author

#1769 was about adding breaking changes section only

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.

@smitpatel

Copy link
Copy Markdown
Contributor

Triage decision was about breaking change only. (At least that was my understanding). And related data section written is not correct.

@roji
roji force-pushed the CartesianExplosion branch from 2e19906 to e8b9209 Compare October 2, 2019 21:27
@roji roji changed the title Doc section and breaking change note on cartesian explosion Breaking change note on cartesian explosion Oct 2, 2019
@roji

roji commented Oct 2, 2019

Copy link
Copy Markdown
Member Author

Removed related data section.

@smitpatel smitpatel changed the title Breaking change note on cartesian explosion Breaking change note on duplicated results in Include Oct 2, 2019
@roji
roji merged commit 2c4b417 into master Oct 2, 2019
@smitpatel
smitpatel deleted the CartesianExplosion branch October 2, 2019 23:39
@AndriySvyryd

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed out by @AndriySvyryd - This comment is incorrect link. ☹️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaking changes note on new single-query behavior and cartesian explosion

3 participants