I\'m trying to use $push in an update query in mongodb, with the c# driver.
$push
The Update.Push(...) method requires a string name (that\'s fin
Update.Push(...)
I know two approaches:
Update.PushWrapped<MyObject>("arrayfield", myObjectInstance); //c# driver >= 1.0
Update.PushWrapped<MyObject>("arrayfield", myObjectInstance);
Or convert your class to BsonValue yourself via ToBsonDocument() extension method.
BsonValue
ToBsonDocument()
Update.Push("arrayfield", myObjectInstance.ToBsonDocument());