public AggregateViewModel GetAggs <T>(string field, string type) { string db = HttpContext.Current.Session["ConString"].ToString(); List <SqlWhere> myWheres = new List <SqlWhere>(); 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); } AggregateViewModel aggModel = new AggregateViewModel(); aggModel.Type = type; aggModel.Field = field; aggModel.Result = _coreService.Aggregate <T>(type, field, myWheres, conName: db); return(aggModel); }