小编mos*_*770的帖子

更新mongodb文档中的特定字段

我使用C#驱动程序在小项目中使用MongoDb,现在我坚持更新文档.试图弄清楚如何更新字段AVG(int)

这是我的代码:

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?>**);
Run Code Online (Sandbox Code Playgroud)

有简单而干净的方法来更新特定字段,如方法ReplaceOne(updatedStudent)?

c# mongodb mongodb-query

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

mongodb ×1

mongodb-query ×1