CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

NHibernate Pagination via Extension Method

370 Views
Copy Code Show/Hide Line Numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
 
namespace Lucilla.Framework.Core.Data
{
    public static class QueryExtensions
    {
        public static IQuery Paginate(this IQuery query, int pageIndex, int pageSize)
        {
            return query
                .SetFirstResult(pageIndex * pageSize)
                .SetMaxResults(pageSize);
        }
    }
}
by andreabalducci
  March 30, 2010 @ 9:24am
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate