如何编写此更新查询以更新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