I'd like to order rows by an integer + number of days passed since today.
However this:
var now = DateTime.UtcNow;
db.Items.OrderBy(x => x.SomeInteger + (x.Date - now).Days);
Gives the following warning:
The LINQ expression 'orderby' could not be translated and will be evaluated locally.
In .NET framework it was possible to use this: DbFunctions.DiffDays
It seems that there isn't any equivalent in ASP.NET Core.
Hello @isonil,
There is a PR for this. (https://github.com/aspnet/EntityFrameworkCore/pull/10264)
Until this is merged, @smitpatel demonstrates how to use this here: https://github.com/aspnet/EntityFrameworkCore/issues/10241#issuecomment-342989770
it's an option until we get this in EF.Functions 馃槉
@ralmsdeveloper Great, thank you. The workaround works.
Most helpful comment
Hello @isonil,
There is a PR for this. (https://github.com/aspnet/EntityFrameworkCore/pull/10264)