Skip to content

Count a projected and included collection once - #35

Merged
SimonCropp merged 1 commit into
mainfrom
count-projected-include-once
Oct 12, 2026
Merged

SimonCropp merged 1 commit into
mainfrom
count-projected-include-once

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

MaxSingleQueryCollections adds the collections Includes name to the collections a projection returns. A query can name one collection both ways:

.Include("Tasks.Employee")
.Select(_ => new Employee { Id = _.Id, Tasks = _.Tasks.ToList() })

The Include there only says what to load under the collection the projection returns. One collection is loaded, and it was counted as two.

Change

An Include path is no longer counted when the projection returns that collection from the same row.

Still counted:

  • Both, when the projection returns the row itself as well, since the Include then loads the collection into it a second time.
  • A further collection included under the projected one.

Impact

A count can only go down, so no query starts to log or throw.

Changes

  • CollectionCounter records the collections a projection returns, by the path an Include would name them with.
  • Three tests in ShapeTests.
  • A paragraph in the readme.
  • Version 0.7.0.

MaxSingleQueryCollections adds the collections Includes name to the
collections a projection returns. A query can name one collection both
ways:

    .Include("Tasks.Employee")
    .Select(_ => new Employee { Id = _.Id, Tasks = _.Tasks.ToList() })

The Include there only says what to load under the collection the
projection returns, so one collection is loaded, and it was counted as
two.

An Include path is no longer counted when the projection returns that
collection from the same row. Both still count when the projection
returns the row itself as well, since the Include then loads the
collection into it a second time. A further collection included under
the projected one still counts.

Version 0.7.0.
@SimonCropp SimonCropp added this to the 0.7.0 milestone Oct 12, 2026
@SimonCropp
SimonCropp merged commit 31cb2f5 into main Oct 12, 2026
5 checks passed
@SimonCropp
SimonCropp deleted the count-projected-include-once branch October 12, 2026 23:46
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