What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?
Also what is the non-HQL way for saying give me the first 15 of a class?
What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?
Also what is the non-HQL way for saying give me the first 15 of a class?
It's actually pretty easy in HQL:
var top15 = session.CreateQuery("from SomeEntity")
.SetFirstResult(0)
.SetMaxResults(15)
.List<SomeEntity>();
Don't know how to do this using the criteria API though.
Criteria API Method:
ICriteria criteria = DaoSession.CreateCriteria(typeof(T));
criteria.SetFirstResult(StartIndex);
criteria.SetMaxResults(MaximumObjects);
return criteria.List<T>();