Translation error when storing NodaTime `(Instant, TimeZoneId)` and filtering on local date time values
thj-dk opened this issue · comments
Tommy Holm Jakobsen commented
I'm attempting to achieve the following query using the latest NodaTime and EF Core packages:
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();
e.Date.Tz
is of course a string representing a Tzdb timezone identifier, e.g. "Pacific/Auckland".
The error returned is "Translation of method 'NodaTime.Instant.InZone' failed."
It this possible or are there better ways to achieve this?
Tommy Holm Jakobsen commented
Closed. This already works. My fault.