You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aayjaychan
changed the title
Enum with EnumToStringConverter always returns 0 in query if casted
Enum with EnumToStringConverter always returns 0 in query if cast to another type
Mar 28, 2022
@ajcvickersint is used as an example. In practice we tried to convert the enum to another enum, which is then returned by ASP.NET Core as string in a JSON API response. This allows us to change the names of the enum values in one layer without affecting the other. We now use a mapping function to work around the issue with projection.
If an enum property has string conversion, querying the property with a cast will always return 0, regardless of what value the property has.
Expected Behaviour
actual
is1
becauseDateTimeKind
has a numeric value of1
.Actual Behaviour
actual
is0
.Include provider and version information
EF Core version: 6.0.3
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 6.0.3
The text was updated successfully, but these errors were encountered: