Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }