-
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
SqlServer: Translate TimeSpan members #19632
Comments
@aleksandar-manukov Yes, we would be interested in a PR for this. We're curious how it deals with time spans that cover more than 24 hours, where the naive mapping to T-SQL |
Hi @ajcvickers Never needed to deal with
This query works with Do you want me to make a PR and to continue discussion there or you need something more advanced to handle |
@aleksandar-manukov Thanks for the additional info. We will discuss. |
|
The DATEDIFF and DATEADD functions don't really have .NET equivalents. |
Hi @bricelam I have never meant to translate |
A PR would be awesome!
Oh I was just doing my due diligence to see what other members we could translate. I only found |
(You may have already seen it, but I have work-in-progress PR out for TimeSpan translations on SQLite) |
@cowmanjoe What SQL were you proposing for the Total* members in PR #19643? |
@bricelam thanks. I will check your PR especially to see what tests I need to do and I will try to make a PR soon. |
@bricelam, initially tried to do a |
The following translations are enabled: | .NET | T-SQL | | --------------------- | -------------------------------- | | timeSpan.Hours | DATEPART(hour, @timespan) | | timeSpan.Minutes | DATEPART(minute, @timespan) | | timeSpan.Seconds | DATEPART(second, @timespan) | | timeSpan.Milliseconds | DATEPART(millisecond, @timespan) | Part of #19632
FYI here's the Npgsql support for these members: npgsql/efcore.pg@c4b353d Npgsql also translates TimeSpan.Days since TimeSpan maps to a real |
Already added in my PR |
Cool, will be looking forward to seeing Where_TimeSpan_Days pass on Npgsql! |
This is related to the fact EF set TimeSpan as Time and not as long in SqlServer? TimeSpan.FromDays(5) -> Exception |
@bricelam Did this ever get any further? I'm trying to do |
@SoftCircuits You have to write it like this for now: |
Hi,
At work, we use a query which uses
TimeSpan
membersHours
,Minutes
andSeconds
, but EFCore doesn't translate these members to sql.We fix the problem creating SqlServerTimeSpanMemberTranslator like the SqlServerDateTimeMemberTranslator and we override the SqlServerMemberTranslatorProvider to include also our SqlServerTimeSpanMemberTranslator.
I think SqlServerTimeSpanMemberTranslator can be useful also to other .NET developers, so if you want I can make a PR to include it to EFCore.SqlServer project.
The text was updated successfully, but these errors were encountered: