public JsonResult GetAllEventCategoryimage(jQueryDataTableParamModel param) { try { var allRecords = new List <CategoryImageEvent>(); allRecords = MS.GetAllEventCategoryimage(); List <CategoryImageEvent> filteredRecords = null; if (!string.IsNullOrWhiteSpace(param.sSearch)) { allRecords = allRecords.Where(t => t.Id.ToString().Contains(param.sSearch.ToLower()) || t.Category.Name.ToLower().ToString().Contains(param.sSearch.ToLower()) || t.Image.ToString().ToLower().Contains(param.sSearch.ToLower())).OrderBy(t => t.Category.Name).ToList(); filteredRecords = allRecords.Skip(param.iDisplayStart).Take(param.iDisplayLength).ToList(); } else { filteredRecords = allRecords .Skip(param.iDisplayStart) .Take(param.iDisplayLength).OrderBy(t => t.Category.Name).ToList(); } int totalRecords = allRecords.Count(); var result = from c in filteredRecords select new[] { "", c.Id.ToString(), c.Category.Name, "/Images/categoryeventimage/" + c.Image, "" }; return(Json(new { sEcho = param.sEcho, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords, aaData = result }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { CommonServices.ErrorLogging(ex); return(Json(new { sEcho = 1, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <string[]> { } }, JsonRequestBehavior.AllowGet)); } }