views:

59

answers:

1

How do I take the "top n" using NHibernate Criteria API? Ideally I'd like to use detached criteria.

+2  A: 

something like:-

criteria.setFirstResult(1);
criteria.setMaxResults(10);

Will take the first 10 results.

Rippo
SetFirstResult is not needed unless you need to skip records/pages.
Diego Mijelshon
Good catch - Thanks Diego
Rippo