Mongodb字段自增长
MongoClient client = new MongoClient("mongodb://xxx.xxx.x.xx:27017"); var mongServer = client.GetServer(); var db = mongServer.GetDatabase("db_test"); var dbclient = db.GetCollection("test"); FindAndModifyArgs arg=new FindAndModifyArgs(); arg.Query = Query.EQ("_id", new ObjectId("5a011a0d59f1654cdc377135")); arg.Update = Update.Inc("Age", 1L); arg.Upsert = true; arg.VersionReturned=FindAndModifyDocumentVersion.Modified; var result = dbclient.FindAndModify(arg); var p = result.ModifiedDocument["Age"].AsInt64;