© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
24 replies
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;
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)
.Where(x => x.Timestamp >= _startDate && x.Timestamp <= _endDate)


Can anyone explain how I can fix that?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How can i make a Condition in .csproj ???
C#CC# / help
3y ago
EF Core
C#CC# / help
2y ago
✅ ef core can't translate a query
C#CC# / help
3y ago
✅ Can I create a Liststring in mssql ef core?
C#CC# / help
4y ago