//public JsonResult GetData(JqSearchIn si) public JsonResult GetData(JqSearchIn si) { int totalRecords; int startRow = (si.page * si.rows) + 1; int skip = (si.page > 0 ? si.page - 1 : 0) * si.rows; // а вот тут пора подключать System.Linq.Dynamic IQueryable <Animal> AnimalsHeap; if (si._search && !String.IsNullOrEmpty(si.filters)) { var wc = si.GenerateWhereClause(typeof(Animal)); AnimalsHeap = _db.Animals.Where(wc.Clause, wc.FormatObjects); totalRecords = AnimalsHeap.Count(); AnimalsHeap = AnimalsHeap .OrderBy(si.sidx + " " + si.sord) .Skip(skip) .Take(si.rows); } else { //AnimalsHeap = db.Animals; //totalRecords = AnimalsHeap.Count(); //AnimalsHeap = AnimalsHeap // .OrderBy(si.sidx + " " + si.sord) // .Skip(skip) // .Take(si.rows); var heap = _db.Animals.ToList(); int totalPagez = _db.Animals.Count(); var result = new JqGridSearchOut { total = totalPagez, page = si.page, // records = totalRecords, rows = (from als in heap select new AnimalItemsJqGridRowOut() { Name = als.Name, TypeName = als.Type.Name, ColorName = als.Color.Name, LocationName = als.Location.Name, LocationRegionName = als.Location.Region.Name }).ToArray() }; return(Json(result)); } var AnimalsList = AnimalsHeap.ToList(); var totalPages = (int)Math.Ceiling((float)totalRecords / si.rows); var grid = new JqGridSearchOut { total = totalPages, page = si.page, records = totalRecords, rows = (from als in AnimalsList select new AnimalItemsJqGridRowOut() { Name = als.Name, TypeName = als.Type.Name, ColorName = als.Color.Name, LocationName = als.Location.Name, LocationRegionName = als.Location.Region.Name }).ToArray() }; return(Json(grid)); }