Skip to content

Count the collections a returned entity brings as loaded by a split query - #1159

Merged
SimonCropp merged 2 commits into
mainfrom
ignored-query-splitting-returned-entity
Nov 30, 2026
Merged

SimonCropp merged 2 commits into
mainfrom
ignored-query-splitting-returned-entity

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

ThrowOnIgnoredQuerySplitting threw "is ignored, since the query loads no collection" for AsSplitQuery and AsSingleQuery on two kinds of query that do load a collection.

  • A collection the returned entity brings. An entity the query returns brings collections with it, that EF loads without an Include: those it owns, and those configured with AutoInclude. Query splitting changes how they are loaded, so it is not ignored. They now count. An owned collection that is mapped to JSON does not, since it is a column of its owner, and neither does an AutoInclude where the query uses IgnoreAutoIncludes. What the query returns is worked out the way IgnoredEntityOperatorDetector does, so an entity that is only read, or a new instance a projection creates, brings nothing.
  • A type with more than one owner. A type that is owned by more than one type has an entity type for each owner, which FindEntityType does not return. A collection of one in a projection was then not seen as a collection of entities. FindEntityTypes is used instead.

The readme says what counts.

…uery

ThrowOnIgnoredQuerySplitting threw for AsSplitQuery and AsSingleQuery on two
kinds of query that do load a collection.

An entity the query returns brings collections with it, that EF loads without
an Include: those it owns, and those configured with AutoInclude. Query
splitting changes how they are loaded, so it is not ignored. They now count,
other than an owned collection that is mapped to JSON, which is a column of
its owner, and an AutoInclude where the query uses IgnoreAutoIncludes.

A type that is owned by more than one type has an entity type for each owner,
which FindEntityType does not return, so a collection of one in a projection
was not seen as a collection of entities. FindEntityTypes is used instead.
@SimonCropp
SimonCropp merged commit a0dc403 into main Nov 30, 2026
3 checks passed
@SimonCropp
SimonCropp deleted the ignored-query-splitting-returned-entity branch November 30, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant