public DataSourceResult Read <T>([DataSourceRequest] DataSourceRequest request, List <SqlWhere> specialWheres = null) { KeyHelper <T> keyHelper = new KeyHelper <T>(); List <SqlWhere> myWheres = new List <SqlWhere>(); List <string> groups = new List <string>(); string db = HttpContext.Current.Session["ConString"].ToString(); if (HttpContext.Current.Session["GridFilterWheres"] != null) { myWheres.AddRange((List <SqlWhere>)HttpContext.Current.Session["GridFilterWheres"]); } if (HttpContext.Current.Session["Searches"] != null) { List <SqlWhere> searchRequest = (List <SqlWhere>)HttpContext.Current.Session["Searches"]; searchRequest.First().Andor = SqlWhereAndOrOptions.SqlWhereAndOr.And; searchRequest.First().Group1 = "("; searchRequest.Last().Group2 = ")"; myWheres.AddRange((HttpContext.Current.Session["Searches"] != null) ? (List <SqlWhere>)HttpContext.Current.Session["Searches"] : null); } if (specialWheres != null) { myWheres = specialWheres; } var totalRecords = _coreService.RecordCount <T>(myWheres); if (request.Groups.Count > 0) { foreach (var g in request.Groups) { groups.Add(g.Member); } } var data = _coreService.LoadModel <T>(myWheres, request.PageSize, request.Page, groups: groups, conName: db); //Iterate through keys and if you find a null value set it to an empty string, needed for kendo dropdown edits for incell editing List <T> tList = new List <T>(); foreach (var item in data) { tList.Add(keyHelper.FixKeys(item)); } request.Page = 1; DataSourceResult result = tList.ToDataSourceResult(request); result.Total = totalRecords; return(result); }