public IQueryable <User> GetUser()
        {
            var criteria = new PageNSort
            {
                Sort       = "Name",
                SortOrder  = SortOrder.Desc,
                PageNumber = 1,
                PageSize   = 2
            };

            return(_userRepo.Search(criteria));
        }
Esempio n. 2
0
        public IQueryable <T> Search(PageNSort PageParam, Expression <Func <T, bool> > expression)
        {
            IQueryable <T> collection;

            if (expression == null)
            {
                collection = RepositoryContext.Set <T>();
            }
            else
            {
                collection = RepositoryContext.Set <T>().Where(expression);
            }

            return(PageNSort(collection, PageParam));
        }
Esempio n. 3
0
        public static IQueryable <T> PageNSort(IQueryable <T> collection, PageNSort PageParam)
        {
            if (PageParam.Sort != null)
            {
                if (PageParam.SortOrder == SortOrder.Asc)
                {
                    collection = collection.OrderBy(x => x.GetType().GetProperty(PageParam.Sort).GetValue(x, null));
                }
                else
                {
                    collection = collection.OrderByDescending(x => x.GetType().GetProperty(PageParam.Sort).GetValue(x, null));
                }
            }

            collection = collection.Skip((PageParam.PageNumber - 1) * PageParam.PageSize).Take(PageParam.PageSize);

            return(collection);
        }
Esempio n. 4
0
        public IQueryable <T> Search(PageNSort PageParam)
        {
            IQueryable <T> collection = RepositoryContext.Set <T>();

            return(PageNSort(collection, PageParam));
        }