How can you do paging with NHibernate?

ICriteria has a SetFirstResult(int i) method, which indicates the index of the first item that you wish to get (basically the first data row in your page).

It also has a SetMaxResults(int i) method, which indicates the number of rows you wish to get (i.e., your page size).

For example, this criteria object gets the first 10 results of your data grid:

criteria.SetFirstResult(0).SetMaxResults(10);

Leave a Comment