Repository navigation
EF-459: Throw for date parts and calendar adds over a Local-kind DateTime property - #378
Open
ajcvickers wants to merge 2 commits into
Open
ajcvickers wants to merge 2 commits into
ajcvickers wants to merge 2 commits into
Conversation
…Time property The driver's LINQ renders date parts and AddYears/AddMonths/AddDays without a timezone, so over a HasDateTimeKind(Local) property the server evaluated them on the stored UTC instant while the entity materializes as local time, silently returning wrong values or rows. Fail loudly until the driver can render a timezone. Also declines the same members over a DateTime member of a projected tuple or record, whose source property cannot be determined. Resolves shared owned types by navigation so a Utc-kind owner is not declined.
Collaborator
Author
|
Note that this does not fix EF-459, it just makes it throw rather than returning wrong data on the driver path. The only reasonable way to fix this is in the driver LINQ itself. |
ajcvickers
marked this pull request as ready for review
October 13, 2026 17:09
ajcvickers
requested review from
adelinowona and
damieng
and removed request for
adelinowona
October 13, 2026 17:09
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Duration additions remain incorrect across DST, and some user-defined record namespaces bypass the projection guard.
2 open findings
What changed in this PR
Prevents incorrect server-side date operations on Local-kind DateTime properties.
Changes:
- Adds translation guards for date parts and calendar additions.
- Adds functional coverage for properties, projections, and bulk updates.
- Documents the breaking behavior change.
| File | Description |
|---|---|
MongoEFToLinqTranslatingExpressionVisitor.cs |
Detects unsafe Local-kind operations. |
LocalKindDateTimeTests.cs |
Adds regression coverage. |
BREAKING-CHANGES.md |
Documents behavior and mitigations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ntify framework types by assembly AddHours/AddMinutes/AddSeconds/AddMilliseconds over a Local-kind DateTime property now throw like AddDays, since the server adds an absolute UTC duration which diverges from local-time arithmetic across a DST transition. IsProjectionContainer identified framework types by a "System" namespace prefix, so a user type in e.g. Systems.Domain bypassed the unresolved-source guard. It now checks the declaring assembly and ITuple.
This branch has not been deployed
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.

The driver's LINQ renders date parts and AddYears/AddMonths/AddDays without a timezone, so over a HasDateTimeKind(Local) property the server evaluated them on the stored UTC instant while the entity materializes as local time, silently returning wrong values or rows. Fail loudly until the driver can render a timezone.
Also declines the same members over a DateTime member of a projected tuple or record, whose source property cannot be determined. Resolves shared owned types by navigation so a Utc-kind owner is not declined.