Skip to content

Additional translations for SQL Server DateTimeOffset#38076

Open
roji wants to merge 3 commits intomainfrom
roji/dto-datetime-utcdatetime-translation
Open

Additional translations for SQL Server DateTimeOffset#38076
roji wants to merge 3 commits intomainfrom
roji/dto-datetime-utcdatetime-translation

Conversation

@roji
Copy link
Copy Markdown
Member

@roji roji commented Apr 10, 2026

Closes #26781
Closes #38074
Closes #34756

@roji roji force-pushed the roji/dto-datetime-utcdatetime-translation branch from 3a23d02 to 49133ed Compare April 10, 2026 09:45
@roji roji marked this pull request as ready for review April 10, 2026 09:45
@roji roji requested a review from a team as a code owner April 10, 2026 09:45
Copilot AI review requested due to automatic review settings April 10, 2026 09:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends EF Core’s SQL Server query translation for temporal APIs, adding more server-side translations for DateTimeOffset members/methods and introducing a SQL Server mapping for DATETRUNC via EF.Functions.DateTrunc, along with cross-provider test updates.

Changes:

  • Add SQL Server translations for DateTimeOffset members (DateTime, UtcDateTime, LocalDateTime), ToOffset(TimeSpan), and new DateTimeOffset(DateTime[, TimeSpan]).
  • Add SQL Server EF.Functions.DateTrunc(datepart, date) translations to DATETRUNC for multiple temporal CLR types.
  • Add/adjust specification and provider functional tests to cover the new translations (and expected failures on non-supporting providers).

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/EFCore.SqlServer/Extensions/SqlServerDbFunctionsExtensions.cs Adds public EF.Functions.DateTrunc overloads for SQL Server.
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerDateTimeMethodTranslator.cs Translates EF.Functions.DateTrunc to DATETRUNC.
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerDateTimeMemberTranslator.cs Adds translations for DateTimeOffset.DateTime, UtcDateTime, LocalDateTime.
src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs Adds translations for DateTimeOffset.Offset.TotalMinutes, ToOffset(TimeSpan), and DateTimeOffset constructors.
src/EFCore.SqlServer/Properties/SqlServerStrings.resx Adds new SQL Server provider error strings for new translation behaviors.
src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs Generated accessors for new SQL Server provider strings.
src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs Adjusts binding behavior to allow provider VisitNew translations in index-based mode.
test/EFCore.Specification.Tests/Query/Translations/Temporal/DateTimeOffsetTranslationsTestBase.cs Adds new baseline tests for DateTimeOffset members/methods/ctors.
test/EFCore.SqlServer.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsSqlServerTest.cs Adds SQL Server baselines for new DateTimeOffset translations + DateTrunc coverage.
test/EFCore.SqlServer.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsSqlServerTest.cs Adds SQL Server baseline tests for DateTrunc over DateTime.
test/EFCore.SqlServer.FunctionalTests/Query/Translations/Temporal/DateOnlyTranslationsSqlServerTest.cs Adds SQL Server baseline tests for DateTrunc over DateOnly.
test/EFCore.SqlServer.FunctionalTests/Query/Translations/Temporal/TimeOnlyTranslationsSqlServerTest.cs Adds SQL Server baseline tests for DateTrunc over TimeOnly.
test/EFCore.Sqlite.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsSqliteTest.cs Updates SQLite overrides for newly added spec tests.
test/EFCore.Cosmos.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsCosmosTest.cs Updates Cosmos overrides for newly added spec tests.
Files not reviewed (1)
  • src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported

@roji roji force-pushed the roji/dto-datetime-utcdatetime-translation branch from 49133ed to 1a8b5a1 Compare April 10, 2026 18:57
Copilot AI review requested due to automatic review settings April 10, 2026 19:32
@roji roji force-pushed the roji/dto-datetime-utcdatetime-translation branch from 1a8b5a1 to ac78b86 Compare April 10, 2026 19:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported

…ressionVisitor.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 19:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 9 comments.

Files not reviewed (1)
  • src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported

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.

SQL Server: translation for DATE_TRUNC SQL Server: Add translation for TODATETIMEOFFSET() SQL Server: Add more DateTimeOffset translations

4 participants