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.
|