我使用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