Beispiel #1
0
        private static DataTableResult <T> ReturnGridData <T>(DataTableParamModel requestParams, ref IQueryable <T> collection)
        {
            List <T> gridData = new List <T>();

            try
            {
                //If only paging
                var skipCollection = collection.Skip(requestParams.iDisplayStart).Take(requestParams.iDisplayLength).ToList().AsQueryable();

                ////If the sort Order is provided perform a sort on the specified column
                //if (requestParams.iSortingCols > 0)
                //{
                //    //var sortCollection = Sort<T>(collection, requestParams.SortOn, requestParams.SortOrd);
                //    var sortCollection = Sort<T>(skipCollection, requestParams.SortOn, requestParams.SortOrd);

                //    //If sort and paging
                //    //gridData = sortCollection.Skip(requestParams.Skip).Take(requestParams.PageSize).ToList();
                //    gridData = sortCollection.ToList();
                //}
                //if (requestParams.FilterField.IsNotEmpty() && requestParams.FilterOperator.IsNotEmpty() && requestParams.FilterValue.IsNotEmpty())
                //{
                //    //var filterCollection = Filter<T>(collection, requestParams.FilterField, requestParams.FilterOperator, requestParams.FilterValue);
                //    var filterCollection = Filter<T>(skipCollection, requestParams.FilterField, requestParams.FilterOperator, requestParams.FilterValue);

                //    //If sort and paging
                //    //gridData = filterCollection.Skip(requestParams.Skip).Take(requestParams.PageSize).ToList();
                //    gridData = filterCollection.ToList();
                //}
                //else
                //{
                //    //If only paging
                //    //gridData = collection.Skip(requestParams.Skip).Take(requestParams.PageSize).ToList();
                //    //gridData = skipCollection.ToList();
                //}
            }
            catch
            {
            }

            return(new DataTableResult <T>
            {
                sEcho = requestParams.sEcho,
                aaData = gridData.Count > 0 ? gridData : collection.ToList(),
                iTotalRecords = collection.Count(),
                iTotalDisplayRecords = gridData.Count(),
            });
        }
Beispiel #2
0
 public static DataTableResult <T> ParseGridData <T>(IQueryable <T> collection, DataTableParamModel requestParams)
 {
     return(ReturnGridData <T>(requestParams, ref collection));
 }