gpt4 book ai didi

c# - IMongoCollection.UpdateOneAsync 中的 OverflowException 尽管未完成任何算术运算

转载 作者:可可西里 更新时间:2023-11-01 10:27:45 27 4
gpt4 key购买 nike

我在 MongoDB.Bson.dll 中遇到 'System.OverflowException'(附加信息:算术运算导致溢出。),当调用 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;
}

有什么问题吗?

最佳答案

是不是跟uint数据类型有关?尝试更新为 int 并告诉我们结果。

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

在这里查看:http://docs.mongodb.org/manual/reference/bson-types/

关于c# - IMongoCollection<T>.UpdateOneAsync 中的 OverflowException 尽管未完成任何算术运算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32018073/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com