1

Given a query for example:

from Users u where u.Country = "US"

I have a web app with a custom grid.

How do I query NHibernate to bring back a specfic page results given page size and index???

Malcolm

Malcolm
  • 12,524
  • 28
  • 89
  • 125
  • 1
    Duplicate: http://stackoverflow.com/questions/54754/how-can-you-do-paging-with-nhibernate – Paco May 13 '09 at 19:59

1 Answers1

3

Use SetFirstResult and SetMaxResults on the query or criteria:

int pagesize = 10;
int page = 2;
query = session.createQuery("...")
  .SetFirstResult(pagesize * page)
  .SetMaxResults(pagesize);
Stefan Steinegger
  • 63,782
  • 15
  • 129
  • 193