Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit result in NHibernate

Tags:

nhibernate

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.

like image 876
Graviton Avatar asked Apr 24 '09 04:04

Graviton


2 Answers

I can just use

public void GetByCriteria(ICriterion criterion)
{
var criteria= ISession.CreateCiteria(typeof(T)).SetMaxResults(maxResult);
criteria.Add(criterion);
}
like image 122
Graviton Avatar answered Nov 13 '22 23:11

Graviton


There is a SetMaxResults method for ICriteria.

like image 32
Craig Avatar answered Nov 13 '22 21:11

Craig