tags:

views:

570

answers:

2

How to limit the number of rows returned in NHibernate?

I am looking for something like SetMaxResult(), but couldn't find it in Nhibernate namespace!

Note: I want to use NHibernate.Criterion, not NHibernate.IQuery, so it's best if you can provide that example.

+1  A: 

There is a SetMaxResults method for ICriteria.

Craig
+1  A: 

I can just use

public void GetByCriteria(ICriterion criterion)
{
var criteria= ISession.CreateCiteria(typeof(T)).SetMaxResults(maxResult);
criteria.Add(criterion);
}
Ngu Soon Hui