MongoCollection<BsonDocument> tblCount;
if (!db.CollectionExists(tblCountName))
{
db.CreateCollection(tblCountName);
}
tblCount = db.GetCollection(tblCountName);
public long Get()
{
FindAndModifyArgs arg = new FindAndModifyArgs();
arg.Query = Query.EQ("_id", "Inc");
arg.Update = Update.Inc("seq", 1L);
arg.Upsert = true;
arg.VersionReturned = FindAndModifyDocumentVersion.Modified;
var result = tblCount.FindAndModify(arg);
return result.ModifiedDocument["seq"].AsInt64;
}