ToPagedList

public static class QueryOverExtensions
    public static PagedList<T> ToPagedList<T>(this IQueryOver<T, T> queryOver, int pageIndex, int pageSize)
    {
        var rowCountQuery = queryOver.ToRowCountQuery();
        IEnumerable<T> list = queryOver.Take(pageSize).Skip((pageIndex - 1) * pageSize).Future();
        int totalCount = rowCountQuery.FutureValue<int>().Value;

        return new PagedList<T>(list, pageIndex, pageSize, totalCount);
    }
}
Example:
public class TeamEmployeeRepository : Repository<TeamEmployee>, ITeamEmployeeRepository
{
    public PagedList<TeamEmployee> GetPagedEmployees(int pageIndex, int pageSize)
    {
        return GetSession().QueryOver<TeamEmployee>()
            .Fetch(x => x.Employee).Eager
            .Fetch(x => x.Team).Eager
            .ToPagedList(pageIndex, pageSize);
    }
}

Description

Paging extension method for NHibernate 3.0 and its new query API QueryOver.

Details

Double click on the code to select all.

 

;