Repository navigation
Add SqlServer translation for DateOnly.ToDateTime(timeOnly) - #35194
Conversation
|
The translation is done as expected but I have issue in the where comparison which compare date with datetime Error Message on test:β SQL sent to the database: SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline]
FROM [Missions] AS [m]
WHERE DATETIMEFROMPARTS(DATEPART(year, [m].[Date]), DATEPART(month, [m].[Date]), DATEPART(day, [m].[Date]), DATEPART(hour, [m].[Time]), DATEPART(minute, [m].[Time]), DATEPART(second, [m].[Time]), DATEPART(millisecond, [m].[Time])) = '1990-11-10T10:15:50.5000000' |
|
@dotnet-policy-service agree |
roji
left a comment
There was a problem hiding this comment.
I think the translation should be to DATETIME2FROMPARTS (which returns SQL Server datetime2), rather than DATETIMEFROMPARTS (which returns the discouraged datetime.
We also need to refrain from doing the translation when either the DateOnly or the TimeOnly are a complex SQL expression (anything other than a column/constant/parameter), for performance reasons; see #35076 (comment).
- use array literal
- use DATETIME2FROMPARTS
- use time 7 fractions instead of milisecond
- add support for constant DateOnly
Fixes dotnet#35194
Fixes dotnet#35076 Co-authored-by: Shay Rojansky <roji@roji.org>
1a76f6f to
e891a51
Compare
roji
left a comment
There was a problem hiding this comment.
@mseada94 thanks for your contribution... In the interest of time, I've rebased this on top of the latest main - porting the test to the new translations test suite - and done a bit of fixup/cleanup. I'll merge once everything's green.
Fixes #35076
I created the PR as draft
please guide where to lookDateOnlyas constant withTimeOnlyProperty