How i can push an item in an Array?
I see that i can insert only basic value (String, Int32, Int64, Boolean) but i can’t insert into an array an INSTANCE of custom class.
//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
);
PushWrappedcoming with driver 1.0 (seems) and simply convert your class toBsonDocument:In case if you using
Update.Pushyou need to do it manually:I am using
ToBsonDocument()to convert some class object toBsonValue.So, just choose what do you like more..