dotnet / dotnet/efcore

work with timespan and compare them

Open
#31,196 2 comments 0 reactions 0 assignees View on GitHub
area-query customer-reported ef6-parity
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Hello guys, i migrate an old .net framework with entity framework 6 app to .NET 7, and i have to deal with time comparison which i don't find equivalent in EF Core. I don't find also documentation about it

the use case is simple, i want for example all events who start before 15h30

in entity framework the code is like that (with dtDeb a DateTime)
````
var lListEvents = dbcontext.Events.Where(e => EntityFunctions.CreateTime(e.DtDeb.Hour, e.DtDeb.Minute, 0) <
EntityFunctions.CreateTime(15, 30, 0) );
````
if ef core, i try this but obviously its not work
````
var lListEvents = dbcontext.Events.Where(e => new Timespan(e.DtDeb.Hour, e.DtDeb.Minute, 0) <
new Timespan(15, 30, 0) );
````

what the best way to achieve this ?

thanks for your help !

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.