我使用C#驅動程序在小型項目中使用MongoDb,現在我堅持更新文檔。 試圖找出如何更新現場AVG(INT)更新mongodb文檔中的特定字段
這裏是我的代碼:
IMongoCollection<Student> studentCollection = db.GetCollection<Student>("studentV1");
Student updatedStudent = new Student() { AVG = 100, FirstName = "Shmulik" });
studentCollection.UpdateOne(
o=>o.FirstName == student.FirstName,
**<What should I write here?>**);
有簡單幹淨的方式類似方法ReplaceOne(updatedStudent)
更新特定領域(S)?
我想你應該閱讀mongodb文檔,它已經涵蓋了與使用c#驅動程序更新相關的所有場景。 https://docs.mongodb.com/getting-started/csharp/update/ – Aby