exception - LiteDB:使用类中没有 BsonID 的更新方法时出错
问题描述
我正在使用 LiteDB,当我在任何没有任何 BsonID 参数的类中使用 Update() 方法时
public class Test
{
public string ServerSecretId { get; set; }
public Dictionary<string, string> webhooks { get; set; }
}
抛出我: 未处理的异常。LiteDB.LiteException:字段“_id”上的 BSON 数据类型“Null”无效。
我不知道是什么原因造成的。这是代码:
{
LiteDatabase db = new LiteDatabase(@"C:\Users\jesus\Downloads\database\db.db");
var x = db.GetCollection<Test>("test");
var y = new Test
{
ServerSecretId = "123456789",
webhooks = new Dictionary<string, string>()
{
{
"webhook1", "c"
}
}
};
x.Insert(y);
y.webhooks["webhook1"] = "a";
x.Update(y);
}
解决方案
推荐阅读
- reactjs - 使用 React Final Form 向 RadioGroup 字段添加自定义道具
- java - 如何适应 hdodenhof circleimageview
- html - 如何使用 Bootstrap 中的按钮在输入上显示无效的验证边框?
- python - 从一周开始的提到的总秒数中找到日期和时间 - python
- android - 使用位图和相机 api 时图像质量下降
- python - 如何使用 APSCHEDULER 安排作业始终在该月的最后一天运行
- sql - 在 Postgres 的 json 列中添加一个数组
- javascript - 如何在 vuejs 中配置 JSME(使用 javascript 配置的化学门户)?
- php - 我无法在 Laravel 6 中显示存储中的文件
- c - 类似函数的宏,“REPORT_ERROR”,已定义 [MISRA 2012 Directive 4.9,咨询]