Esempio n. 1
0
        int SaveOrUpdate <T>(MongoDBEntity obj)
        {
            var collection = GetCollection <MongoDBEntity>(this.server, dbName, typeof(T).Name);

            return((int)collection.ReplaceOne(c => c._id == obj._id, obj, new UpdateOptions {
                IsUpsert = true
            }).MatchedCount);
        }
Esempio n. 2
0
        int Delete <T>(MongoDBEntity obj)
        {
            var collection = GetCollection <MongoDBEntity>(this.server, dbName, typeof(T).Name);

            return((int)collection.DeleteOne(c => c._id == obj._id).DeletedCount);
        }
Esempio n. 3
0
        int Update <T>(MongoDBEntity obj)
        {
            var collection = GetCollection <MongoDBEntity>(this.server, dbName, typeof(T).Name);

            return((int)collection.ReplaceOne(c => c._id == obj._id, obj).MatchedCount);
        }