-
Type: Bug
-
Resolution: Fixed
-
Priority: Blocker - P1
-
Affects Version/s: 2.19.0, 2.19.1, 2.19.2, 2.20.0
-
Component/s: None
-
None
-
Fully Compatible
-
Not Needed
-
Summary
Unable to cast object of type 'MongoDB.Bson.Serialization.Serializers.Int32Serializer' to type 'MongoDB.Driver.Linq.Linq3Implementation.Serializers.IEnumUnderlyingTypeSerializer
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
Please refer the following code where I receive error while using an ENUM value (VehicleType)vehicle.Type with mongodb c# driver version 2.19 & above
How to Reproduce
cehcileInfo = await (from vehicle in _mongodb.Vehicles.AsQueryable()
where vehicle.Id == vehicleId
select new VehicleMetaData()
{ Id = vehicle.Id, CustomerId = vehicle.CustomerId, Name = vehicle.Name, Type = (VehicleType)vehicle.Type, }
).FirstOrDefaultAsync();
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.