Retrieve paged lists from DAL theo codeutil.wordpress.com
Objective: Create an easy way to retrieve paged lists from the data access layer when using Entity Framework. Steps: Create an interface that defines a paged list: IPagedList<T> . Create a class PagedList<T> that implements IPagedList<T>. Create a Linq extension method that can be applied to an Entity Framework query and returns a paged list. Optional: If you are using the repository pattern you can use IPagedList<T> to return paged lists. Code :) 1. Define an interface for the paged list. 1 2 3 4 5 6 7 8 9 10 11 12 13 using System.Collections.Generic; namespace Demo.Paging { public interface IPagedList<T> { int PageSize { get ; } int TotalNumberOfItems { get ; } IList<T> CurrentPage { get ; } int CurrentPageNumber { get ; } int TotalNumberOfPages { get ; } } } 2. Implement the class for t