Fix duplicate joins when materializing writable projectables with includes#218
Open
PhenX wants to merge 1 commit into
Open
Fix duplicate joins when materializing writable projectables with includes#218PhenX wants to merge 1 commit into
PhenX wants to merge 1 commit into
Conversation
…ludes A writable [Projectable] property triggers a whole-entity re-projection so the property can be populated during materialization. That re-projection read every other mapped member through its compiler-generated backing field (what EF's member metadata resolves auto-properties to). Reading a mapped scalar or navigation through the backing field stops EF's navigation expansion from recognizing it as a plain column/navigation, so EF instead materializes the entire source entity -- including any Include-ed collection navigation -- once per rewritten member, emitting one duplicate JOIN per member (issue #217). Read each member through its CLR property instead, and bind to the property when it is settable so the projection keeps natural column names. EF then treats scalars as columns and collapses the collection navigation into a single join. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Xvb9UMRqFJKpocKCCeYcc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A writable [Projectable] property triggers a whole-entity re-projection so
the property can be populated during materialization. That re-projection read
every other mapped member through its compiler-generated backing field
(what EF's member metadata resolves auto-properties to). Reading a mapped
scalar or navigation through the backing field stops EF's navigation
expansion from recognizing it as a plain column/navigation, so EF instead
materializes the entire source entity -- including any Include-ed collection
navigation -- once per rewritten member, emitting one duplicate JOIN per
member (issue #217).
Read each member through its CLR property instead, and bind to the property
when it is settable so the projection keeps natural column names. EF then
treats scalars as columns and collapses the collection navigation into a
single join.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_016Xvb9UMRqFJKpocKCCeYcc