public DeleteResult DeleteMany <T>(Expression <Func <T, bool> > expression, IMongoDBStateContext stateContext = null) where T : class
        {
            var result = GetCollection <T>(stateContext).DeleteMany <T>(expression);

            return(result);
        }
        public async Task <DeleteResult> DeleteManyAsync <T>(Expression <Func <T, bool> > expression, IMongoDBStateContext stateContext = null) where T : class
        {
            var result = await GetCollection <T>(stateContext).DeleteManyAsync <T>(expression);

            return(result);
        }
        public async Task <UpdateResult> UpdateManyAsync <T>(Expression <Func <T, bool> > expression, UpdateDefinition <T> updateDef, IMongoDBStateContext stateContext = null) where T : class
        {
            var result = await GetCollection <T>(stateContext).UpdateManyAsync <T>(expression, updateDef);

            return(result);
        }
        public async Task <ReplaceOneResult> ReplaceOneAsync <T>(T @object, Expression <Func <T, bool> > key, UpdateOptions options, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(key);

            var result = await GetCollection <T>(stateContext).ReplaceOneAsync(filter, @object, options);

            return(result);
        }
        public List <P> FindAndProjectEmbeddedDocuments <T, P>(BsonDocument[] pipeline, IMongoDBStateContext stateContext = null) where T : class
        {
            var result = GetCollection <T>(stateContext).Aggregate <P>(pipeline).ToList();

            return(result);
        }
        public T FindOneAndUpdate <T>(Expression <Func <T, bool> > expression, UpdateDefinition <T> updateDef, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(expression);

            var result = GetCollection <T>(stateContext).FindOneAndUpdate <T>(filter, updateDef);

            return(result);
        }
        public List <P> FindAndProjectMany <T, P>(Expression <Func <T, P> > projectionParameter, Expression <Func <T, bool> > searchParameters, IMongoDBStateContext stateContext = null) where T : class
        {
            var projection = Builders <T> .Projection.Expression(projectionParameter);

            var filter = Builders <T> .Filter.And(searchParameters);

            return(GetCollection <T>(stateContext).Find(filter).Project(projection).ToList());
        }
        public async Task <StoreResult <T> > InsertSingleAsync <T>(T @object, IMongoDBStateContext stateContext = null) where T : class
        {
            await GetCollection <T>(stateContext).InsertOneAsync(@object);

            return(new StoreResult <T>(true, @object, null));
        }
        public async Task <IEnumerable <T> > FindAllAysnc <T>(Expression <Func <T, bool> > expression, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(expression);

            var result = await  GetCollection <T>(stateContext).FindAsync <T>(filter).ConfigureAwait(false);

            //Task.WaitAny(result);
            return(result.ToList());
        }
Exemplo n.º 10
0
        public async Task <IEnumerable <T> > FindAllAysnc <T>(Expression <Func <T, bool> > expression, FindOptions <T> options, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(expression);

            var result = await  GetCollection <T>(stateContext).FindAsync <T>(filter, options).ConfigureAwait(true);

            // await Task.WhenAll(result);
            return(result.ToList());
            //Task<IEnumerable<T>> t =await result;
            //return Task.FromResult(result);
        }
Exemplo n.º 11
0
        public IEnumerable <T> FindAll <T>(Expression <Func <T, bool> > expression, FindOptions <T> options, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(expression);

            return(GetCollection <T>(stateContext).FindSync <T>(filter, options).ToList());
        }
Exemplo n.º 12
0
        public async Task <StoreResult <T> > InsertManyAsync <T>(IEnumerable <T> objects, IMongoDBStateContext stateContext = null) where T : class
        {
            await GetCollection <T>(stateContext).InsertManyAsync(objects);

            return(new StoreResult <T>(true, null, objects));
        }
Exemplo n.º 13
0
 public StoreResult <T> InsertMany <T>(IEnumerable <T> objects, IMongoDBStateContext stateContext = null) where T : class
 {
     GetCollection <T>(stateContext).InsertMany(objects);
     return(new StoreResult <T>(true, null, objects));
 }
Exemplo n.º 14
0
        public async Task <T> FindOneAndDeleteAsync <T>(Expression <Func <T, bool> > expression, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(expression);

            var result = await GetCollection <T>(stateContext).FindOneAndDeleteAsync <T>(filter);

            return(result);
        }
Exemplo n.º 15
0
        public IEnumerable <T> FindUsingRegex <T>(string fieldName, string searchKey, RegexOptions options, IMongoDBStateContext stateContext = null) where T : class
        {
            var regex  = new BsonRegularExpression(new Regex(searchKey, options));
            var filter = Builders <T> .Filter.Regex(fieldName, regex);

            var result = GetCollection <T>(stateContext).Find <T>(filter).ToList();

            return(result);
        }
Exemplo n.º 16
0
        public T FindOneAndDelete <T>(Expression <Func <T, bool> > expression, FindOneAndDeleteOptions <T> options, IMongoDBStateContext stateContext = null) where T : class
        {
            var filter = Builders <T> .Filter.And(expression);

            var result = GetCollection <T>(stateContext).FindOneAndDelete <T>(filter, options);

            return(result);
        }
Exemplo n.º 17
0
 public StoreResult <T> InsertSingle <T>(T @object, IMongoDBStateContext stateContext = null) where T : class
 {
     GetCollection <T>(stateContext).InsertOne(@object);
     return(new StoreResult <T>(true, @object, null));
 }