MongoDB
 sql >> Datenbank >  >> NoSQL >> MongoDB

So verwenden Sie den Positionsoperator $ in MongoDB C#-Treiberversion 2

Sie können so etwas versuchen.

var builder = Builders<Student>.Filter;
var filter = builder.Eq(student=> student.Id, 1) & builder.ElemMatch(student => student.Grades, x => x == 80);

var builder = Builders<Student>.Update;
var update = builder.Set(student => student.Grades[-1], 82);

var result = collection.UpdateOne(filter, update);