public dynamic GetGeneralType([FromBody] Newtonsoft.Json.Linq.JObject param) { dynamic obj = param; var mainQuery = Enumerable.Repeat(new { id = default(int), stateid = default(int?), name = default(string), type = default(string), isactive = default(bool) }, 0).AsQueryable(); int currentPage = Convert.ToInt32(obj.gridState.skip.Value); int rowsPerPage = Convert.ToInt32(obj.gridState.take.Value); string sortField = null; string sortBy = ""; if (obj.gridState.sort.Count > 0) { var sort = obj.gridState.sort[0]; sortBy = sort.dir == null ? sortBy : sort.dir.Value; sortField = sort.field.Value; } if (sortField == null || sortField == "") { sortField = "Name"; } if (sortBy == null || sortBy == "") { sortBy = "desc"; } mainQuery = _repositoryWrapper.General.GetGeneralTypes(); if (obj.type.ToString() != "") { string type = obj.type.Value.ToString(); mainQuery = mainQuery.Where(m => m.type == type); } var objSort = new SortModel(); objSort.ColId = sortField; objSort.Sort = sortBy; var sortList = new System.Collections.Generic.List <SortModel>(); sortList.Add(objSort); mainQuery = mainQuery.OrderBy(sortList); var tmpList = PaginatedList <dynamic> .Create(mainQuery, currentPage, rowsPerPage); var objtotal = tmpList.TotalRecords; var objresult = tmpList.Select(x => new { id = x.id, stateid = x.stateid, type = x.type, Name = x.name, isactive = x.isactive }).ToList(); dynamic objresponse = new { data = objresult, dataFoundRowsCount = objtotal }; return(objresponse); }