We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem:
The following exception is thrown when selecting DateInterval.End:
InvalidCastException: Reading as 'NodaTime.LocalDate' is not supported for fields having DataTypeName 'timestamp without time zone'
Entity
public class User { public DateInterval IntervalField { get; set; } = new(LocalDate.MinIsoValue, LocalDate.MaxIsoValue); }
Query
var result = await dbContext.Set<User>() .Select(x => x.IntervalField.End) .FirstOrDefaultAsync(); }
Cause:
Accessing DateInterval.End generates the following SQL:
... upper(u.interval_field) - INTERVAL 'P1D' ...
The result is of type 'timestamp without time zone'. This should be casted to date.
Workaround:
You can force EF to generate the correct sql:
Working query
var result = await dbContext.Set<User>() .Select(x => (LocalDate)(object)x.IntervalField.End) .FirstOrDefaultAsync(); }
This generates the following SQL:
... CAST(upper(u.interval_field) - INTERVAL 'P1D' AS date) ...
The text was updated successfully, but these errors were encountered:
Cast NodaTime DateInterval.End to date. Fixes npgsql#3015
e685457
Cast NodaTime DateInterval.End to date.
90bc036
Fixes npgsql#3015
Cast NodaTime DateInterval.End to date. (#3024)
f9e3428
Fixes #3015 Co-authored-by: Daniel Haas <dhaas@phoenis.de>
f958e9a
Fixes #3015 Co-authored-by: Daniel Haas <dhaas@phoenis.de> (cherry picked from commit f9e3428)
haas-daniel
Successfully merging a pull request may close this issue.
Problem:
The following exception is thrown when selecting DateInterval.End:
InvalidCastException: Reading as 'NodaTime.LocalDate' is not supported for fields having DataTypeName 'timestamp without time zone'
Entity
Query
Cause:
Accessing DateInterval.End generates the following SQL:
The result is of type 'timestamp without time zone'. This should be casted to date.
Workaround:
You can force EF to generate the correct sql:
Working query
This generates the following SQL:
The text was updated successfully, but these errors were encountered: