【发布时间】:2014-12-14 16:14:25
【问题描述】:
我正在使用 .NET 应用程序并尝试插入 MongoDB。 我正在使用 InsertBatch 并将其传递给 Newtonsoft.Json.Linq.JObject 的 IEnumerable
我得到的错误:
{"Serializer DictionarySerializer<String, JToken> expected serialization options of type DictionarySerializationOptions, not DocumentSerializationOptions."}
我的代码是:
private void InsertItemsToMongo(IEnumerable<JObject> list)
{
MongoClient = new MongoClient("mongodb://localhost:27017");
var myDb = mongo.GetServer().GetDatabase("MyDatabase");
if (!myDb.CollectionExists("MyStuff");
myDb.CreateCollection("MyStuff");
MongoCollection<JObject> myCollection = myDb.GetCollection<JObject>("MyStuff");
myCollection.InsertBatch(list);
}
错误在 InsertBatch 行抛出。
如果您需要任何其他信息,请提供,我只提供了我认为相关的信息。
谢谢!
【问题讨论】: