Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlServerDateOnlyMemberTranslator referencing DateTime instead of DateOnly #32392

Closed
JohnJVTK opened this issue Nov 22, 2023 · 1 comment · Fixed by #32415
Closed

SqlServerDateOnlyMemberTranslator referencing DateTime instead of DateOnly #32392

JohnJVTK opened this issue Nov 22, 2023 · 1 comment · Fixed by #32415
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-cleanup

Comments

@JohnJVTK
Copy link

SqlServerDateOnlyMemberTranslator referencing DateTime instead of DateOnly

I needed to implement my own SqlServerDateOnlyMemberTranslator and saw that DatePartMapping was using DateTime instead of DateOnly.
It makes no error but it's more about logic. Is it expected ?

public class SqlServerDateOnlyMemberTranslator : IMemberTranslator
{
    private static readonly Dictionary<string, string> DatePartMapping
        = new()
        {
            { nameof(DateTime.Year), "year" },
            { nameof(DateTime.Month), "month" },
            { nameof(DateTime.DayOfYear), "dayofyear" },
            { nameof(DateTime.Day), "day" }
        };
   ...
}
in src/EFCore.SqlServer/Query/Internal/SqlServerDateOnlyMemberTranslator.cs

Include provider and version information

EF Core version: 8.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: (e.g. .NET 8.0)
Operating system: Windows 11
IDE: Visual Studio 2022 17.8

@roji
Copy link
Member

roji commented Nov 26, 2023

@JohnJVTK this doesn't affect program behavior in any way, but I submitted #32415 to fix it for consistency/esthetic reasons.

@roji roji self-assigned this Nov 26, 2023
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 26, 2023
@roji roji added this to the 9.0.0 milestone Nov 27, 2023
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview1 Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-cleanup
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants