2
배열에서 항목을 밀어 넣을 수 있습니까? 기본 값 (String, Int32, Int64, Boolean) 만 삽입 할 수 있지만 사용자 정의 클래스의 인스턴스에 배열을 삽입 할 수 없다는 것을 알았습니다.MongoDB C# Update.PushWrapped, 어떻게 사용합니까?
Update.PushWrapped<i_Player>("_player", myPlayer);
을 경우 당신이 Update.Push
를 사용하는 경우 수동으로 수행해야합니다 :
//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
);