O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Paged Queries in the data access layer

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, I'll show you how we can easily add paging to a QueryOver query object in our DAL.

Getting ready

Complete the recipe, Using Named Queries in the data access layer.

How to do it...

  1. In Eg.Core.Data.Queries, add a class using the following code:
    public class PagedResult<T>
    {
    
      public int TotalItems { get; set; }
      public IEnumerable<T> PageOfResults { get; set; }
    
    }
  2. Add an interface using the following code:
    public interface IPagedQuery<T>
      : IQuery<PagedResult<T>>
    {
    
      int PageNumber { get; set; }
      int ItemsPerPage { get; set; }
    
    }
  3. In Eg.Core.Data.Impl.Queries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required