14
私は辞書を利用しています。 .insert()の後に "_t"と "_v"があります。ここの2つの投稿でserializationがJSON first then BSONに変換されています。私はJSON-TO-BSON行う場合、それはおよそMYDOCにBsonDocumentを変換することはできません文句を言い、MongoDBへの挿入時に_tと_vを防ぐ方法は?
mCollection.InsertOne(x);
IMongoCollection<myDoc> mCollection = Db.GetCollection<myDoc>("whatever");
をMongoDBののドライバv2.4.3を使用しています。 IMongoCollection<BsonDocument> mCollection = Db.GetCollection<BsonDocument>("whatever");
に切り替えると、_tと_vが表示されます。
_tと_vを避けるにはどうすればよいですか?ここで
データの種類と活用の私のコードです:
public class myObjForDictionary
{
//...
}
public class myDoc
{
// ... some other elements, then Dictionary
public Dictionary<string, object> myDictionary { get; set; }
}
// to instantiate the
class myClass
{
// define MongoDB connection, etc.
// instantiate myDoc and populate data
var x = new myDoc
{
//...
myDictionary = new Dictionary<string, object>
{
{ "type", "something" },
{ "Vendor", new object[0] },
{ "obj1", //data for myObjForDictionary
}
};
}
}
同じ問題... – Catalin
@MatthewJamesDavisこれで必要なものは何ですか?この問題は、BSONとしてオブジェクトのJSONではなくBSONとしてオブジェクトを保存しようとするために発生します –