Exemplo n.º 1
0
        public IEnumerable <T> Page <T>(
            ISpecification <T> spec,
            int offsetPage = 0, int pageSize = 10,
            ISortFactory <T, long> sortFactory = null,
            bool track = false, bool incSoftDel = false,
            params Expression <Func <T, object> >[] includes)
            where T : BaseEntity
        {
            var filtered = FindAll(spec, track, incSoftDel, includes);

            IOrderedQueryable <T> results;

            if (sortFactory != null)
            {
                results = sortFactory.ApplySorts(filtered);
            }
            else
            {
                results = filtered.OrderBy(t => t.Id);
            }

            var query = results
                        .Skip(offsetPage * pageSize)
                        .Take(pageSize);

            return(query.ToList());
        }
Exemplo n.º 2
0
        public IOrderedQueryable <T> Page <T>(
            ISpecification <T> spec,
            ISortFactory <T, TKey> sortFactory,
            int offsetPage = 0, int pageSize = 10,
            params Expression <Func <T, object> >[] includes)
            where T : class, IEntity <TKey>
        {
            var filtered = FindAll(spec, includes);
            var results  = sortFactory.ApplySorts(filtered);

            var query = (IOrderedQueryable <T>)results
                        .Skip(offsetPage * pageSize)
                        .Take(pageSize);

            return(query);
        }