tags:

views:

468

answers:

1

Hi,

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

+3  A: 

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