Open julienGrd opened 1 year ago
Note for triage: this is the SQL generated by EF6:
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[DtDeb] AS [DtDeb]
FROM [dbo].[Books] AS [Extent1]
WHERE (convert (time,convert(varchar(255), DATEPART (hour, [Extent1].[DtDeb])) + ':' + convert(varchar(255), DATEPART (minute, [Extent1].[DtDeb])) + ':' + str(cast(0 as float(53)), 10, 7), 121)) < (convert (time,convert(varchar(255), 15) + ':' + convert(varchar(255), 30) + ':' + str(cast(0 as float(53)), 10
, 7), 121))
The EF6 translation is likely horrible perf-wise. You could just compare the components yourself:
var lListEvents = dbcontext.Events.Where(e => e.DtDeb.Hour < 15 || (e.DtDeb.Hour == 15 && e.DtDeb.Minute < 30));
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)
if ef core, i try this but obviously its not work
what the best way to achieve this ?
thanks for your help !