-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
SQL Server: translate dateOnly.ToDateTime(timeOnly)
to DATETIMEFROMPARTS
#35076
Comments
Putting in the backlog as a possible translation. One problem with this kind of translation is that it duplicates its argument (in this many times over); this is OK if the argument is a simple value (column), but if it's e.g. a complex scalar subquery, that would reevaluate the subquery many times over. At least at first, I'd not perform the translation in that case. |
dateOnly.ToDateTime(timeOnly)
should be transformed to EF.Functions.DateTimeFromParts
dateOnly.ToDateTime(timeOnly)
to DATETIMEFROMPARTS
@mseada94 sure thing, go ahead. |
I will start by adding two tests should these test be enough? [ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Where_DateOnly_ToDateTime_With_Constant_TimeOnly(bool async)
=> AssertQuery(
async,
ss => ss.Set<Mission>()
.Where(o => o.Date.ToDateTime(new TimeOnly(21, 5, 19, 94)) == new DateTime(1990, 11, 10, 21, 5, 19, 94))
.AsTracking());
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Where_DateOnly_ToDateTime_With_Property_TimeOnly(bool async)
=> AssertQuery(
async,
ss => ss.Set<Mission>()
.Where(o => o.Date.ToDateTime(o.Time) == new DateTime(1990, 11, 10, 10, 15, 50, 500))
.AsTracking()); |
@mseada94 please submit a PR rather than posting implementation questions here - I'll review the PR (though it may take some time). |
I created the PR as draft
|
As title.
Transform to
which would then translate (using the current mapping of
EF.Functions.DateTimeFromParts
) to the SQLThe text was updated successfully, but these errors were encountered: