title: MongoDb : How to make partial updates from json data with the official C# driver
body: <p>I want to make a general method to do PARTIAL updates of a document from json data. The json data contiains a subset of the fields of the POCO being updated. I have this:</p>
  
  <pre><code>    public static void Update(MongoCollection collection, ObjectId id, string jsonData) {
           // assume jsonData does not contain the id field.
          var bsonDoc = BsonSerializer.Deserialize&lt;BsonDocument&gt;(jsonData);  
          IMongoUpdate updateDoc = new UpdateDocument("$set", bsonDoc);
          collection.Update(Query.EQ("_id",id), updateDoc);
      }
  </code></pre>
  
  <p>This almost works, but my problem is that fields with type ObjectId are deserialized as strings, because that is how they are represented in JSON. (They have been serialized with the javascript JSON2 lib on the client side).</p>
  
  <p>So my questions are: </p>
  
  <p>1) What is the best way to make a general partial update method working with json data in with the official C# driver? 
  2) How can I get poco fields deserialized correctly to the proper types instead of just strings when using the BsonSerializer?</p>