private static IQueryable <T> PerformQuery <T>(this IDataServiceComponent dataService, IQueryable <T> entities, out IQueryable <T> totalCountQuery) where T : class { totalCountQuery = null; RequestContext reqCtxt = RequestContext.Current; QueryRequest queryInfo = reqCtxt.CurrentQueryInfo; entities = PerformFilter(dataService, entities, queryInfo.filterInfo, queryInfo.GetDbSetInfo()); if (queryInfo.isIncludeTotalCount) { totalCountQuery = entities; } entities = PerformSort(dataService, entities, queryInfo.sortInfo); entities = GetPage(dataService, entities, queryInfo.pageIndex, queryInfo.pageSize, queryInfo.pageCount, queryInfo.GetDbSetInfo()); return(entities); }