コード例 #1
0
        private MongoCollection <T> GetCollectionFor <T>()
        {
            var db   = GetDb();
            var name = CollectionNamesFactory.GetCollectionNameFromType <T>();

            return(db.GetCollection <T>(name));
        }
コード例 #2
0
        public int GetNextSequenceFor <T>()
        {
            var collection = GetDb()["NumericSequences"];
            var seqName    = CollectionNamesFactory.GetCollectionNameFromType <T>();
            var query      = Query.EQ("_id", seqName);

            collection.Update(query, new UpdateBuilder().Inc("next", 1), UpdateFlags.Upsert);
            var result = collection.FindOne(query)["next"];

            return(result.AsInt32);
        }