2
我如何推送一個數組中的項目? 我看到我只能插入基本的值(String,Int32,Int64,Boolean),但我無法在數組中插入自定義類的INSTANCE。MongoDB c#Update.PushWrapped,如何使用它?
//in this way, it work:
var myPlayer = new i_Player();
this.mongo_collection.FindAndModify(
Query.EQ("_id",ID),
SortBy.Ascending("_id"),
Update.PushWrapped<i_Player>("_player", myPlayer),
true
);
// in this way, don't work because i_Player is not an BsonValue but is my CLASS!
var myPlayer = new i_Player();
this.mongo_collection.FindAndModify(
Query.EQ("_id",ID),
SortBy.Ascending("_id"),
Update.Push("_player", myPlayer),
true
);