Skip to content

Add opt-out flag for Autmatic Hydrating Settable Properties - #226

Open
zmerdev wants to merge 1 commit into
EFNext:masterfrom
zmerdev:feat/populate-settable-properties-opt-out
Open

zmerdev wants to merge 1 commit into
EFNext:masterfrom
zmerdev:feat/populate-settable-properties-opt-out

Conversation

@zmerdev

@zmerdev zmerdev commented Sep 25, 2026

Copy link
Copy Markdown

Proposed fix for #224

Adds opt-out via

UseProjectables(o => o.PopulateSettableProperties(false))

Hydrating settable projectables when whole entities are loaded (#84) is a behavior change for anyone upgrading from previous versions (I Upgraded from v3 to v6): a materialized entity now carries database-computed values for those properties, and the query rewrite behind it also materializes navigations that were never Include-ed. Callers who only ever project explicitly can now opt out and keep the older semantics. Projectables are still expanded wherever a query reads them; only the assignment onto materialized entities goes away. Enabled by default, so nothing changes unless a caller opts out.

Applies to CompatibilityMode.Full. The Limited path builds its replacer through ExpressionExtensions.ExpandProjectables, which has no access to context options, so it is unaffected -- as it already is by the #132 tracking check, which it also does not see.

Tests: two new QueryRootTests cases covering both sides of PopulateSettableProperties(false): a plain entity query is not rewritten, and a projectable read in a Select is still expanded.

Filling in settable projectables when whole entities are loaded (EFNext#84) is a
behaviour change for anyone upgrading from before it: a materialized entity
now carries database-computed values for those properties, and the query
rewrite behind it also materializes navigations that were never Include-ed.
Callers who only ever project explicitly can now opt out and keep the older
semantics. Projectables are still expanded wherever a query reads them; only
the assignment onto materialized entities goes away. Enabled by default, so
nothing changes unless a caller opts out.

Applies to CompatibilityMode.Full. The Limited path builds its replacer
through ExpressionExtensions.ExpandProjectables, which has no access to
context options, so it is unaffected -- as it already is by the EFNext#132 tracking
check, which it also does not see.

Tests: two new QueryRootTests cases covering both sides of
PopulateSettableProperties(false): a plain entity query is not rewritten, and
a projectable read in a Select is still expanded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zmerdev
zmerdev marked this pull request as ready for review September 25, 2026 20:56
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