How do I take the "top n" using NHibernate Criteria API?

Ben Aston picture Ben Aston · Jul 20, 2010 · Viewed 8.5k times · Source

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

Answer

Rippo picture Rippo · Jul 20, 2010

something like:-

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

Will take the first 10 results.