NHibernate HQL's Equivalent to T-SQL's TOP Keyword
问题 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? 回答1: 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. 回答2: Criteria API Method: ICriteria criteria = DaoSession.CreateCriteria(typeof(T)); criteria.SetFirstResult(StartIndex); criteria.SetMaxResults