Skip to content

Name the collections in the MaxSingleQueryCollections message - #50

Merged
SimonCropp merged 1 commit into
mainfrom
name-single-query-collections
Nov 6, 2026
Merged

SimonCropp merged 1 commit into
mainfrom
name-single-query-collections

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

A query over MaxSingleQueryCollections only said how many collections it loaded side by side, so the developer had to read the query to find which Include to move to a query of its own.

The violation now carries the collections in query order, each named as the entity it is from and the navigations to it, and the exception message and log line list them:

MaxSingleQueryCollections: 2 exceeds 1. The query loads Employee.Tasks, Employee.Department.Employees side by side. Load one of them in a query of its own, or use AsSplitQuery()
  • CollectionCounter returns the counted collections' names rather than a count. Includes are visited source first so they come out in query order. A nested chain is named by the collection at its end; projected collections are named too, and a projected subquery as DbSet<T>.
  • QueryComplexityViolation.Collections exposes the list, null for every other level.
  • Readme documents the naming under "Collections in a single query".
  • Tests: a snapshot of the thrown message, a check that the logged warning names both navigations, and name tests for nested, restated, string, projected, and projected-plus-included cases.

The rule itself is unchanged.

A query over the level only said how many collections it loaded side by side, so the developer had to read the query to find which Include to move to a query of its own. The violation now carries the collections, in query order, named as the entity they are from and the navigations to them, and the message and log line list them.
@SimonCropp SimonCropp added this to the 1.0.0 milestone Nov 6, 2026
@SimonCropp
SimonCropp merged commit 747b118 into main Nov 6, 2026
5 checks passed
@SimonCropp
SimonCropp deleted the name-single-query-collections branch November 6, 2026 11:04
@SimonCropp
SimonCropp restored the name-single-query-collections branch November 6, 2026 11:37
@SimonCropp
SimonCropp deleted the name-single-query-collections branch November 6, 2026 11:38
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.

1 participant