-
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
Add DATEFROMPARTS function to SqlServer #19400
Conversation
src/EFCore.SqlServer/Query/Internal/SqlServerDateTime2FromPartsFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerDateFromPartsFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerDateTime2FromPartsFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeOffsetFromPartsFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerSmallDateTimeFromPartsFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerTimeFromPartsFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
@Marusyk please fix the failing test, ideally convert the added tests to AssertQuery pattern and add tests for each method (datetime2, datetimeoffset, smalldatetime, time). Looks good otherwise |
Could anyone suggest? var count = context.Orders
.Count(c => new TimeSpan(23, 59, 0) > EF.Functions.TimeFromParts(12, 12, 31, 5, 1)); it throws
|
Use at least one argument which is range variable from server side. (i.e. using c) |
how about: Orders.Select(o => new { o.OrderID, Time = EF.Functions.TimeFromParts(12, 12, 31, 5, o.OrderId % 60) }) |
@Marusyk thank you for the contribution! |
public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments) | ||
{ | ||
if (_dateFromPartsMethodInfo.Equals(method)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor to set function name and return server type using case block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Should I create a new PR for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do it. I may have small clean up tasks in other unrelated PRs too.
Contributes #19237
Add
DATEFROMPARTS
functionPlease review,
Thank you in advance