Exemplo n.º 1
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());
        }