Format:
Recent snippets matching tags of paging
/// <summary> /// Returns a page worth of items from the specified collection. /// </summary> /// <typeparam name="TSource">the type of the items in the collection</typeparam> /// <param name="source">an IEnumerable>TSource< of items to page</param> /// <param name="pageNumber">the number of the page to return</param> /// <param name="itemsPerPage">the number of items that make up a page</param> /// <returns> /// An IEnumerable>TSource< the contains the specified number of items for the specified pageNumber. /// If pageNumber exceeds the number of available pages, the returned collection will be empty.
298 Views
no comments
public static List<T> Page<T, TResult, TResult1>(this List<T> obj, int page, int pageSize, System.Linq.Expressions.Expression<Func<T, TResult>> keySelector, bool asc, out int rowsCount, bool isThenBy, System.Linq.Expressions.Expression<Func<T, TResult1>> thenByClause) { rowsCount = obj.Count(); if (asc) { if (isThenBy) return obj.AsQueryable().OrderBy(keySelector).ThenBy(thenByClause).Skip((page == 0 ? 0 : page - 1) * pageSize) .Take(pageSize).ToList();
550 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
