I’m attempting to achieve the following query using LINQ, EF Core, NodaTime and Postgres SQL:
select * from "TimeEntries"
where "Date_Instant" at time zone "Date_Tz" >= '2024-06-10'
This is my attempt:
await db.TimeEntries
.Where(e =>
e.Date.Instant.InZone(DateTimeZoneProviders.Tzdb[e.Date.Tz]).LocalDateTime > local)
.ToListAsync();
Where e.Date.Instant
is NodaTimes’ Instant
type and e.Date.Tz
is a string representing a Tzdb timezone identifier, e.g. “Pacific/Auckland”.
The error returned is “Translation of method ‘NodaTime.Instant.InZone’ failed.”
From my understanding when reading the docs, this should…maybe work?
It this possible or are there better ways to achieve this using LINQ?