NHibernate的HQL的相当于T-SQL的TOP关键词关键词、HQL、NHibernate、TOP

2023-09-03 11:55:59 作者:佀个废物

什么是NHibernate的HQL的相当于T-SQL的TOP关键字?

What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?

还什么是非HQL方式说给我的前15个一类?

Also what is the non-HQL way for saying give me the first 15 of a class?

推荐答案

它实际上是美元的HQL p $ ptty的方便:

It's actually pretty easy in HQL:

var top15 = session.CreateQuery("from SomeEntity")
                .SetFirstResult(0)
                .SetMaxResults(15)
                .List<SomeEntity>();

不知道如何使用标准的API,虽然做到这一点。

Don't know how to do this using the criteria API though.