Exemplo n.º 1
0
        public static List <T> PaginatedList <T>(IQueryable <T> source, PagingBaseRequestModel pagingModel)
        {
            if (pagingModel == null)
            {
                pagingModel = new PagingBaseRequestModel();
            }

            var prop = typeof(T).GetProperty(pagingModel.Sorting?.SortBy);

            if (prop != null)
            {
                var isAscending = pagingModel.Sorting?.SortDir == "asc";
                source = source.OrderByAsQueryable(prop.Name, isAscending);
            }

            var pagedList = source.Skip(pagingModel.Paging.Offset).Take(pagingModel.Paging.Limit).ToList();

            return(pagedList);
        }
 public PagingBaseRequest()
 {
     PagingModel = new PagingBaseRequestModel();
 }