Beispiel #1
0
        public FormatedList ParseForClientSide(IQueryable <T> queriable)
        {
            var list = new FormatedList();

            list.aaData = queriable
                          .AsEnumerable()
                          .Select(SelectProperties)
                          .ToList();
            return(list);
        }
Beispiel #2
0
        public FormatedList Parse(IQueryable <T> queriable)
        {
            var request = GetRequestFromHttpContext();
            var list    = new FormatedList();

            list.Import(properties.Select(x => x.Name).ToArray());
            list.sEcho = request.TableEcho;

            //var totalCount = queriable.Count();
            var orderedQueryable = ApplySort(queriable, request);
            var setData          = orderedQueryable.Select(x => new PreFilterTotal <T> {
                Val = x
            });
            var unpagedData = setData.Where(ApplyGenericSearch(request));

            unpagedData = unpagedData.Where(IndividualPropertySearch(request));

            var filteredCount = unpagedData.Count();
            var postFilter    = unpagedData.Select(x => new PostFilterTotal <T>
            {
                Val = x.Val
            });

            var pagedResults = postFilter
                               .Skip(request.Skip)
                               .Take(request.Take);
            var results = pagedResults.ToList();

            if (!results.Any())
            {
                list.aaData = new List <T>().Select(SelectProperties);
                return(list);
            }

            list.aaData = results.Select(x => x.Val).Select(SelectProperties).ToList();
            list.iTotalDisplayRecords = filteredCount;
            list.iTotalRecords        = filteredCount;

            return(list);
        }