如何編寫此更新查詢以更新c#中的mongo記錄。如何編寫更新查詢來更新mongodb中的多個字段?
db.collection.update({ "S_Id" : 110 },{ "Name" : "Name1","Batch" : "43","Date":"9/2/2011", "Status" : 0 });
我'嘗試這樣
IMongoUpdate update = new UpdateDocument();
if (Named != null) { update = Update.Set("Name", "Name1"); }
if (Date != null) { update = Update.Set("Date", "18/02/2013"); }
if (Batch != null) { update = Update.Set("Batch",43); }
coll.Update(query, update);
是我'做正確的或我必須做什麼樣的方式,請讓我繼續的正確方法。
謝謝@Soner Gonul,下次我會糾正我的錯誤。 – siva 2013-02-18 14:16:53