IMongoCollection中的OverflowException <t> .UpdateOneAsync尽管没有进行算术运算

时间:2015-08-14 20:21:58

标签: c# mongodb

我在调用'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;
}

可能出现什么问题?

1 个答案:

答案 0 :(得分:2)

是否与uint数据类型有关?尝试更新到int并告诉我们结果。

正如您在MongoDB文档中看到的那样,支持的可用BSON类型不包括uint32。

在此处查看:http://docs.mongodb.org/manual/reference/bson-types/