Example #1
0
        public IQueryable <T> FindByCondition(Expression <Func <T, bool> > expression, PageRequest <T> pageRequest, params Expression <Func <T, Object> >[] includeExps)
        {
            IQueryable <T> query = RepositoryContext.Set <T>().AsQueryable();

            if (pageRequest.HasOrderBy())
            {
                query = pageRequest.OrderBy(query);
            }

            if (expression != null)
            {
                query = query.AsExpandable().Where(expression);
            }

            if (includeExps != null)
            {
                query = includeExps.Aggregate(query, (current, exp) => current.Include(exp));
            }

            if (pageRequest != null && pageRequest != null)
            {
                query = query.Skip((pageRequest.Page - 1) * pageRequest.PageSize).Take(pageRequest.PageSize);
            }

            return(query.AsNoTracking());
        }
Example #2
0
        public IQueryable <T> FindAll(PageRequest <T> pageRequest)
        {
            IQueryable <T> query = RepositoryContext.Set <T>();

            if (pageRequest.HasOrderBy())
            {
                query = pageRequest.OrderBy(query);
            }

            if (pageRequest != null && pageRequest != null)
            {
                query = query.Skip((pageRequest.Page - 1) * pageRequest.PageSize).Take(pageRequest.PageSize);
            }

            return(query.AsNoTracking());
        }
Example #3
0
        public IQueryable <T> FindByCondition(Expression <Func <T, bool> > expression, PageRequest <T> pageRequest)
        {
            IQueryable <T> query = RepositoryContext.Set <T>();

            if (pageRequest.HasOrderBy())
            {
                query = pageRequest.OrderBy(query);
            }

            if (expression != null)
            {
                query = query.AsExpandable().Where(expression);
            }

            if (pageRequest != null && pageRequest != null)
            {
                query = query.Skip((pageRequest.Page - 1) * pageRequest.PageSize).Take(pageRequest.PageSize);
            }

            return(query.AsNoTracking());
        }