/// <summary> /// GetPageData /// </summary> /// <typeparam name="TEntity"></typeparam> /// <typeparam name="TKey"></typeparam> /// <param name="querableList"></param> /// <param name="orderByKeySelector"></param> /// <param name="pageParam"></param> /// <param name="bIsAscOrder"></param> /// <param name="strOrder">Id Asc, Date Desc</param> /// <returns>PageData<TEntity></returns> public static PageData <TEntity> GetPageData <TEntity, TKey>(IQueryable <TEntity> querableList , Expression <Func <TEntity, TKey> > orderByKeySelector , PageParam pageParam, bool bIsAscOrder = true, string strOrder = "") { pageParam.Check(); PageData <TEntity> pageData = new PageData <TEntity>(pageParam, querableList.Count()); IQueryable <TEntity> orderQuerableList = null; if (string.IsNullOrEmpty(strOrder)) { orderQuerableList = bIsAscOrder ? querableList.OrderBy(orderByKeySelector) : querableList.OrderByDescending(orderByKeySelector); } else { orderQuerableList = querableList.OrderBy(strOrder); } int intPageSkip = pageParam.GetPageSkip(); pageData.Data = orderQuerableList.Skip(intPageSkip) .Take(pageParam.PageSize).ToList(); return(pageData); }
/// <summary> /// GetPageData /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="querableList"></param> /// <param name="pageParam"></param> /// <returns>IQueryable<TEntity></returns> public static IQueryable <TEntity> GetPageData <TEntity>(IQueryable <TEntity> orderQuerableList, PageParam pageParam) { int intPageSkip = pageParam.GetPageSkip(); return(orderQuerableList.Skip(intPageSkip).Take(pageParam.PageSize)); }