public void Delete(Specification.ISpecification <TEntity> specification, bool autoSaveChanges = true) { Delete(specification.Predicate, false); if (autoSaveChanges) { _context.SaveChanges(); } }
/// <summary> /// <see cref="IRepository{T, TId}"/> /// </summary> /// <param name="specification"><see cref="IRepository{T, TId}"/></param> /// <param name="sortDescriptors"><see cref="IRepository{T, TId}"/></param> /// <returns><see cref="IRepository{T, TId}.FindBy"/></returns> public virtual IEnumerable <T> FindBy( Specification.ISpecification <T> specification, params SortDescriptor <T>[] sortDescriptors) { var query = Query; query = query .FindBy <T, TId>(specification) .Sort <T, TId>(sortDescriptors); return(query.ToArray()); }
public Task <T> GetBySpecAsync(Specification.ISpecification <T> specification) { if (specification.CacheEnabled) { string key = $"{specification.CacheKey}-GetBySpecAsync"; _logger.LogInformation("Checking cache for " + key); return(_cache.GetOrCreate(key, entry => { entry.SetOptions(_cacheOptions); _logger.LogWarning("Fetching source data for " + key); return _sourceRepository.GetBySpecAsync(specification); })); } return(_sourceRepository.GetBySpecAsync(specification)); }
/// <summary> /// <see cref="IRepository{T, TId}"/> /// </summary> /// <param name="specification"><see cref="IRepository{T, TId}"/></param> /// <param name="pageIndex"><see cref="IRepository{T, TId}"/></param> /// <param name="pageSize"><see cref="IRepository{T, TId}"/></param> /// <param name="sortDescriptors"><see cref="IRepository{T, TId}"/></param> /// <returns><see cref="IRepository{T, TId}"/></returns> public virtual IEnumerable <T> FindPageBy( Specification.ISpecification <T> specification, int pageIndex, int pageSize, params SortDescriptor <T>[] sortDescriptors) { var query = Query; query = query .FindBy <T, TId>(specification) .Sort <T, TId>(sortDescriptors) .Paginate(pageIndex, pageSize); return(query.ToArray()); }
/// <inheritdoc/> public Task <List <T> > ListAsync(Specification.ISpecification <T> specification, CancellationToken cancellationToken = default) { if (specification.CacheEnabled) { string key = $"{specification.CacheKey}-ListAsync"; _logger.LogInformation("Checking cache for " + key); return(_cache.GetOrCreate(key, entry => { entry.SetOptions(_cacheOptions); _logger.LogWarning("Fetching source data for " + key); return _sourceRepository.ListAsync(specification, cancellationToken); })); } return(_sourceRepository.ListAsync(specification, cancellationToken)); }
public IEnumerable <TEntity> List(Specification.ISpecification <TEntity> spec) { // fetch a Queryable that includes all expression-based includes var queryableResultWithIncludes = spec.Includes .Aggregate(_dbContext.Set <TEntity>().AsQueryable(), (current, include) => current.Include(include)); // modify the IQueryable to include any string-based include statements var secondaryResult = spec.IncludeStrings .Aggregate(queryableResultWithIncludes, (current, include) => current.Include(include)); // return the result of the query using the specification's criteria expression return(secondaryResult .Where(spec.Criteria) .AsEnumerable()); }
public Task <List <TResult> > ListAsync <TResult>(Specification.ISpecification <T, TResult> specification) { throw new NotImplementedException(); }
public IList <TEntity> Find(Specification.ISpecification <TEntity> specification, bool IsNoTracking = true) { return(GetQuery(specification, IsNoTracking).ToList()); }
public IQueryable <TEntity> GetQuery(Specification.ISpecification <TEntity> specification, bool IsNoTracking = true) { return(GetQuery(specification.Predicate, IsNoTracking)); }
/// <inheritdoc/> public Task <TResult> GetBySpecAsync <TResult>(Specification.ISpecification <T, TResult> specification, CancellationToken cancellationToken = default) { throw new NotImplementedException(); }
/// <inheritdoc/> public Task <int> CountAsync(Specification.ISpecification <T> specification, CancellationToken cancellationToken = default) { // TODO: Add Caching return(_sourceRepository.CountAsync(specification, cancellationToken)); }
public Task <TResult> GetBySpecAsync <TResult>(Specification.ISpecification <T, TResult> specification) { throw new NotImplementedException(); }
public IQueryable <TEntity> GetModel(Action <IRepositories.Commons.IOrderable <TEntity> > orderBy, Specification.ISpecification <TEntity> specification) { var linq = new Orderable <TEntity>(GetModel(specification)); orderBy(linq); return(linq.Queryable); }
public async Task <IList <TEntity> > FindAsync(Specification.ISpecification <TEntity> specification, bool IsNoTracking = true) { return(await GetQuery(specification.Predicate).ToListAsync()); }
public async Task <TEntity> SingleAsync(Specification.ISpecification <TEntity> specification, bool IsNoTracking = true) { return(await SingleAsync(specification.Predicate)); }
public IQueryable <TEntity> GetModel(Action <IRepositories.Commons.IOrderable <TEntity> > orderBy, Specification.ISpecification <TEntity> specification) { var queryable = GetModel().Where(specification.SatisfiedBy()).AsQueryable(); var linq = new Orderable <TEntity>(queryable); orderBy(linq); return(linq.Queryable); }
public TEntity Find(Specification.ISpecification <TEntity> specification) { return(GetModel().FirstOrDefault(specification.SatisfiedBy())); }
public IQueryable <TEntity> GetModel(Specification.ISpecification <TEntity> specification) { return(GetModel().Where(specification.SatisfiedBy())); }
public TEntity GetSingleBySpec(Specification.ISpecification <TEntity> spec) { return(List(spec).FirstOrDefault()); }
public async Task <IQueryable <TEntity> > GetQueryAsync(Specification.ISpecification <TEntity> specification, bool IsNoTracking = true) { return(await GetQueryAsync(specification.Predicate)); }
public Task <int> CountAsync(Specification.ISpecification <T> specification) { // TODO: Add Caching return(_sourceRepository.CountAsync(specification)); }
public TEntity Single(Specification.ISpecification <TEntity> specification, bool IsNoTracking = true) { return(Single(specification.Predicate, IsNoTracking)); }
public TEntity Find(Specification.ISpecification <TEntity> specification) { return(Find(specification.SatisfiedBy())); }