couchdb-2.0 - 使用 ArmChair 将新文档添加到 CouchDb 会引发异常 Object reference not set to an instance of an object
问题描述
我正在使用沙发数据库 2.2.0 版
我想couchdb
使用 .Net
所以我安装了Armchair.Core
Nuget Package 版本 0.11.2
为了添加新文档,我遵循了尚未完成的 wiki 中提到的代码 https://bitbucket.org/dboneslabs/arm-chair/wiki/main-api/session-api.md
Database mydatabase = new Database("TestDb",newConnection("http://localhost:5984"));
using (var session = mydatabase.CreateSession())
{
var author = new Person("Jone");
session.Add(author);// NOTE: If no Id has been assigned before the instance is added to the Session, then ArmChair will assign it. After the object is committed to the database, the revision will then be set onto the instance
session.Commit();
}
但我仍然收到错误
Object reference not set to an instance of an object.
即使我在构造函数中传递了它们,mydatabase
前面代码中提到的变量也有值 nullConnection
和参数,因为它根本没有连接到 couchdb 数据库并且从不尝试创建数据库 TestDbDataBase
请提供任何帮助,我的代码中是否有任何错误调用
解决方案
ArmChair 连接到现有数据库并且不创建数据库。
如果要创建数据库,请查看示例应用程序,在 Autofac 注册中有一个方法可以确保创建了数据库。
它不是最漂亮的代码,但可以工作。
推荐阅读
- python - 如何从输入分配到类中的对象
- cassandra - Cassandra 在插入后更新前几行
- gitlab - 在没有个人“私人令牌”的情况下调用 GitLab API
- c# - 需要覆盖导航方法
- google-cloud-platform - Google Cloud CDN 开始忽略存储分区的查询字符串
- r - R - 具有不同列的矩阵的总和列表
- r - 如何使用零膨胀回归模型进行预测?
- python - 在加入 2 个列表时添加空字符串 - Python
- android - Android Studio 生成对 .iml 文件的不需要的 java 源文件夹引用
- azure - 使用 CoreOS,我们在安装 IoTEdge 运行时遇到了困难