IMongoCollection中的OverflowException.UpdateOneAsync,尽管没有做算
本文关键字:UpdateOneAsync 中的 OverflowException IMongoCollection | 更新日期: 2023-09-27 18:07:56
我遇到了一个'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;
}
怎么了?
与int数据类型无关吗?尝试更新为int并告诉我们结果。
正如你在MongoDB文档中看到的,可用的BSON类型支持不包括uint32。
点击这里查看:http://docs.mongodb.org/manual/reference/bson-types/