2017-03-22 15 views
14

私は辞書を利用しています。 .insert()の後に "_t"と "_v"があります。ここの2つの投稿でserializationJSON 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を避けるにはどうすればよいですか?ここで

enter image description here

データの種類と活用の私のコードです:

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 
       } 
      }; 
     } 

    } 
+0

同じ問題... – Catalin

+0

@MatthewJamesDavisこれで必要なものは何ですか?この問題は、BSONとしてオブジェクトのJSONではなくBSONとしてオブジェクトを保存しようとするために発生します –

答えて

0

私はあなたが箱から出してあなたに異なるオプションのカップルを与えDictionarySerializationOption ...を探しているのだと思います辞書がどのようにシリアライズされるかを決定します。

関連する問題