Skip to content

Where queries with casted enum value throw Can't write CLR type #489

@onimoger

Description

@onimoger

After upgrading to version 2.1 started getting errors with such queries:
var t = VehicleTypes.Truck;
context.Vehicles.Where(x => x.TypeId == (int)t)
throwing exception:

System.InvalidCastException: Can't write CLR type VehicleTypes with handler type Int32Handler

If code is changed to:
int t = (int)VehicleTypes.Truck;
context.Vehicles.Where(x => x.TypeId == t)
it works.

I guess it's because of new strict parameter type handling, but is this really the place for it trigger error? The enum value is supplied with a cast to correct type.
Is this intended? It would require a lot of refactoring in our project.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions