public IQueryable <TAggregateRoot> FindAll <TAggregateRoot>(Specifications.ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, Storage.SortOrder sortOrder) where TAggregateRoot : class, IAggregateRoot { EnsureSession(); IQueryable <TAggregateRoot> result = null; var query = this._session.Query <TAggregateRoot>() .Where(specification.Expression); switch (sortOrder) { case Storage.SortOrder.Ascending: if (sortPredicate != null) { result = query.OrderBy(sortPredicate); } break; case Storage.SortOrder.Descending: if (sortPredicate != null) { result = query.OrderByDescending(sortPredicate); } break; default: result = query; break; } Commit(); return(result); }
public TAggregateRoot Find <TAggregateRoot>(Specifications.ISpecification <TAggregateRoot> specification) where TAggregateRoot : class, IAggregateRoot { EnsureSession(); var result = this._session.Query <TAggregateRoot>().Where(specification.Expression).FirstOrDefault(); Commit(); return(result); }
public PagedResult <TAggregateRoot> FindAll <TAggregateRoot>(Specifications.ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, Storage.SortOrder sortOrder, int pageNumber, int pageSize) where TAggregateRoot : class, IAggregateRoot { EnsureSession(); if (pageNumber <= 0) { throw new ArgumentOutOfRangeException("pageNumber", pageNumber, "The pageNumber is one-based and should be larger than zero."); } if (pageSize <= 0) { throw new ArgumentOutOfRangeException("pageSize", pageSize, "The pageSize is one-based and should be larger than zero."); } if (sortPredicate == null) { throw new ArgumentNullException("sortPredicate"); } var query = this._session.Query <TAggregateRoot>() .Where(specification.Expression); int skip = (pageNumber - 1) * pageSize; int take = pageSize; int totalCount = 0; int totalPages = 0; List <TAggregateRoot> pagedData = null; PagedResult <TAggregateRoot> result = null; switch (sortOrder) { case Storage.SortOrder.Ascending: totalCount = query.ToFutureValue(x => x.Count()).Value; totalPages = (totalCount + pageSize - 1) / pageSize; pagedData = query.OrderBy(sortPredicate).Skip(skip).Take(take).ToFuture().ToList(); result = new PagedResult <TAggregateRoot>(totalCount, totalPages, pageSize, pageNumber, pagedData); break; case Storage.SortOrder.Descending: totalCount = query.ToFutureValue(x => x.Count()).Value; totalPages = (totalCount + pageSize - 1) / pageSize; pagedData = query.OrderByDescending(sortPredicate).Skip(skip).Take(take).ToFuture().ToList(); result = new PagedResult <TAggregateRoot>(totalCount, totalPages, pageSize, pageNumber, pagedData); break; default: break; } Commit(); return(result); }
public bool Exists(Specifications.ISpecification <TAggregateRoot> specification) { var count = _efContext.Context.Set <TAggregateRoot>().Count(specification.IsSatisfiedBy); return(count != 0); }
public void SaveSumResult <TResult>(System.Linq.Expressions.Expression <Func <TEntity, TResult> > selector, Specifications.ISpecification <TEntity> criteria, TResult sum) { }
public void SaveLongCountResult(Specifications.ISpecification <TEntity> criteria, long count) { }
public bool TrySumResult <TResult>(System.Linq.Expressions.Expression <Func <TEntity, TResult> > selector, Specifications.ISpecification <TEntity> criteria, out TResult sum) { sum = default(TResult); return(false); }
public bool TryLongCountResult(Specifications.ISpecification <TEntity> criteria, out long count) { count = default(long); return(false); }
public void SaveCountResult(Specifications.ISpecification <TEntity> criteria, int count) { }
public bool TryCountResult(Specifications.ISpecification <TEntity> criteria, out int count) { count = default(int); return(false); }
public void SaveFindResult <TResult>(Specifications.ISpecification <TEntity> criteria, Repositories.Queries.IQueryOptions <TEntity> queryOptions, System.Linq.Expressions.Expression <Func <TEntity, TResult> > selector, TResult result) { }
public bool TryFindResult <TResult>(Specifications.ISpecification <TEntity> criteria, Repositories.Queries.IQueryOptions <TEntity> queryOptions, System.Linq.Expressions.Expression <Func <TEntity, TResult> > selector, out TResult result) { result = default(TResult); return(false); }