我在调用'System.OverflowException' in MongoDB.Bson.dll
时遇到Additional information: Arithmetic operation resulted in an overflow.
(UpdateOneAsync
)而不明白为什么:
CarSpec spec = GetSpec();
var updateDefinition = Builders<Cars>.Update.Set(c => c.Spec, spec);
IMongoCollection<CarBatch> carsBatch = GetCarsBatch();
var result = await carsBatch.UpdateOneAsync(c => c.Id == car.Id, updateDefinition);
这些是重要的数据结构:
public class Car {
public string Id;
public ServiceVersion CurrentVersion = new ServiceVersion();
public CarSpec Spec = new CarSpec();
public List<StatusNotice> StatusNotifications = new List<StatusNotice>();
}
public class CarSpec {
internal const uint InitialChasisNumber = 1000000000;
public uint ChasisNumber = InitialChasisNumber;
public uint DoorsCount;
}
可能出现什么问题?
答案 0 :(得分:2)
是否与uint数据类型有关?尝试更新到int并告诉我们结果。
正如您在MongoDB文档中看到的那样,支持的可用BSON类型不包括uint32。