Reference resources:
1:mongodb3.2 System Learning--3, update () operation
2:c# manipulating MongoDB Sub-documents
The code is as follows:
varMongostring ="mongodb://xxxxxxxxxxx:27017"; varHost =NewTmongodbhostmodel {CollectionName="ft_test", ConnectionString=mongostring, DatabaseName="system_db" }; varperson =NewPerson {Id=Objectid.generatenewid (), Name="jamesbing", Address=NewList<addressitem> { NewAddressitem {Add ="United Kingdom", Id = Objectid.generatenewid (), age = A}, NewAddressitem {Add ="United States", Id = Objectid.generatenewid (), age = +} } }; varCollection = Tmongodbhelper.getmongocollection<person>(host. ConnectionString, host. DatabaseName, host. CollectionName); //Update childdocument varAddress ="address.$. {0}"; varresult =collection. Findandmodify (Query.and (NewList<imongoquery>{Query.eq ("_id",NewObjectId ("577b344a87aebb23c0fc767a")), Query.eq ("address._id",NewObjectId ("577b344a87aebb23c0fc767b"), }), MongoDB.Driver.Builders.Update.Set (string. Format (Address," Age"), Bsonvalue.create ( -)));
C # Update MongoDB sub-document implementation method