In an effort to avoid overwhelming the user and increase application responsiveness, large result sets are commonly broken into smaller pages of results. In this recipe, we'll show you how to easily add paging to a QueryOver
query object in our DAL.
In
Eg.Core.Data.Queries
, add a class using the following code:public class PagedResult<T> { public int TotalCount { get; set; } public IEnumerable<T> Items { get; set; } }
Add an interface using the following code:
public interface IPagedQuery<T> : IQuery<PagedResult<T>> { int PageNumber { get; set; } int PageSize { get; set; } }
In
Eg.Core.Data.Impl.Queries
, add the following class:public abstract class PagedQueryOverBase<T> : NHibernateQueryBase<PagedResult<T>>, IPagedQuery<T> { public PagedQueryOverBase(ISessionFactory sessionFactory...