Beispiel #1
0
        /// <summary>
        /// Paged data
        /// </summary>
        /// <typeparam name="TAggregateRoot"></typeparam>
        /// <param name="pageIndex">started from 1</param>
        /// <param name="pageCount"></param>
        /// <param name="specification"></param>
        /// <param name="sortPredicate"></param>
        /// <param name="sortOrder"></param>
        /// <returns></returns>
        public IEnumerable <TAggregateRoot> GetPagedList <TAggregateRoot>(int PageIndex, int PageSize, ISpecification <TAggregateRoot> Specification, Expression <Func <TAggregateRoot, dynamic> > SortPredicate, DBSortOrder SortOrder)
            where TAggregateRoot : class, new()
        {
            //TODO:mCommandTimeout / Specification cannot be null
            var query = mdbContext.Set <TAggregateRoot>().Where(Specification.SatisfiedBy());

            //if (Specification != null)
            //{
            //    query = query.Where(Specification.SatisfiedBy());
            //}
            switch (SortOrder)
            {
            case DBSortOrder.Ascending:
                if (SortPredicate != null)
                {
                    query = query.OrderBy(SortPredicate);
                }
                break;

            case DBSortOrder.Descending:
                if (SortPredicate != null)
                {
                    query = query.OrderByDescending(SortPredicate);
                }
                break;

            default:
                break;
            }
            return(query.Skip(PageSize * (PageIndex - 1)).Take(PageSize).ToList());
        }
Beispiel #2
0
        public List <TEntityRoot> GetEntityList <TEntityRoot>(ISpecification <TEntityRoot> Specification, Expression <Func <TEntityRoot, object> > SortPredicate, DBSortOrder SortOrder) where TEntityRoot : class, new()
        {
            //TODO:mCommandTimeout
            var query = mdbContext.Set <TEntityRoot>().Where(Specification.SatisfiedBy());

            switch (SortOrder)
            {
            case DBSortOrder.Ascending:
                if (SortPredicate != null)
                {
                    return(query.OrderBy(SortPredicate).AsEnumerable().ToList());
                }
                break;

            case DBSortOrder.Descending:
                if (SortPredicate != null)
                {
                    return(query.OrderByDescending(SortPredicate).AsEnumerable().ToList());
                }
                break;

            default:
                break;
            }

            return(query.AsEnumerable().ToList());
        }
Beispiel #3
0
 /// <summary>
 /// Paged data
 /// </summary>
 /// <typeparam name="TAggregateRoot"></typeparam>
 /// <param name="pageIndex">started from 1</param>
 /// <param name="pageCount"></param>
 /// <param name="sortPredicate"></param>
 /// <param name="sortOrder"></param>
 /// <returns></returns>
 public IEnumerable <TAggregateRoot> GetPagedList <TAggregateRoot>(int PageIndex, int PageSize, Expression <Func <TAggregateRoot, dynamic> > SortPredicate, DBSortOrder SortOrder)
     where TAggregateRoot : class, new()
 {
     return(this.GetPagedList(PageIndex, PageSize, new TrueSpecification <TAggregateRoot>(), SortPredicate, SortOrder));
 }
Beispiel #4
0
 public List <TEntityRoot> GetEntityList <TEntityRoot>(Expression <Func <TEntityRoot, object> > SortPredicate, DBSortOrder SortOrder) where TEntityRoot : class, new()
 {
     return(GetEntityList(new TrueSpecification <TEntityRoot>(), SortPredicate, SortOrder));
 }