【发布时间】:2018-02-17 15:23:08
【问题描述】:
我正在使用 Azure cosmos dB Emulator 使用 MongoDB C# 驱动程序在 MongoDB 上执行 CRUD 操作。 我能够在模拟器中使用 C# 创建数据库和集合。这是我创建数据库和集合的示例代码..
IMongoDatabase db = dbClient.GetDatabase("<My DB name>");
db.CreateCollection("<Collection Name>");
这些查询工作正常,但是当我尝试将示例数据插入此集合时,它会抛出错误
命令插入失败:处理此请求时发生未知服务器错误..
我插入示例数据的示例代码是
IMongoCollection<UserProfile> collection = db.GetCollection<UserProfile("<Collection Name>");
UserProfile c = new UserProfile();
c.ID = 21;
c.UserName = "<Some Name> ";
c.Email = "<Email ID>";
collection.InsertOne(c);
如何使用 MongoDB C# 驱动程序在 Azure cosmos dB 模拟器中执行 CRUD 操作以及如何在模拟器中运行 mongo 查询而不是 SQL 查询? 提前致谢
【问题讨论】:
标签: c# mongodb-.net-driver azure-cosmosdb