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

DbFunctions does not have DateDiff for DatetimeOffset #12376

Closed
SamHuo213 opened this issue Jun 15, 2018 · 4 comments
Closed

DbFunctions does not have DateDiff for DatetimeOffset #12376

SamHuo213 opened this issue Jun 15, 2018 · 4 comments

Comments

@SamHuo213
Copy link

Hi,

I am currently using EF Core 2.1 with Postgresql. I have some Entities that use DatetimeOffset. When I try to do a difference on two DateTimeOffset the operation is happening on client side. I tried looking into DbFunctions for performing DateTimeOffset diff on client side but can't seem to find the methods in DbFunctions.

The following code is what I am trying to accomplish

context.Entity
.Where(x => EF.Functions.DateDiffSeconds(x.ExpirationTime, DateTimeOffset.UtcNow))
.ToList();

@ralmsdeveloper
Copy link
Contributor

AFAIK: This is being supported only by SQL Server.

@SamHuo213
Copy link
Author

Thanks for the reply. Will this be supported in the future? Is there any other way I can do Diffs on DateTimeOffset on the server side besides raw sql?

@ajcvickers
Copy link
Contributor

@SamHuo213 We did some investigation into data handling by different database engines and came to the conclusion that DateDiff is a mostly SQL Server construct. Other providers are more able to translate the regular DateTime methods, which is more natural anyway. See #10656 for more details.

This means that it is up to the PostgreSQL provider to determine appropriate translations for DateTime operations, preferably based on translations of normal BCL methods, but potentially also with function mappings where appropriate. You should file an issue on https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL

@B-Esmaili
Copy link

Then you better call it SQLServer.Functions not EF.Functions , and even better call the framework SqlSeverFramework not EntityFramework. That is a shame!

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants