C#C
C#3y ago
Rese

❔ How can I make a function of a simple condition EF Core translatable

Hey, so I have this function, but it seems to throw an error by not being translatable by EF Core, even though if the code is extracted from the function, it seems to work just fine.

Function that cannot be translated:
public static bool IsWithinRange(this DateTime target, DateTime rangeStart, DateTime rangeEnd)
        => target >= rangeStart && target <= rangeEnd;


But this is fine:
.Where(x => x.Timestamp >= _startDate && x.Timestamp <= _endDate)


Can anyone explain how I can fix that?
Was this page helpful?