【Nhibernate】HQL 分页

 

HQL

 IQuery query =
                NHibernateHelper.OpenSession()
                    .CreateQuery(
                        @"from Product");

            query.SetFirstResult(2);
            query.SetMaxResults(10);

           
            var result = query.List<Product>();

 

MSSQL

SELECT TOP (@p0) Id0_,
       Name0_,
       Category0_,
       Disconti4_0_
FROM
  (SELECT product0_.Id AS Id0_,
          product0_.Name AS Name0_,
          product0_.Category AS Category0_,
          product0_.Discontinued AS Disconti4_0_,
          ROW_NUMBER() OVER(
                            ORDER BY CURRENT_TIMESTAMP) AS __hibernate_sort_row
   FROM Product product0_) AS query
WHERE query.__hibernate_sort_row > @p1
ORDER BY query.__hibernate_sort_row;

@p0 = 10 [Type: Int32 (0)],
         @p1 = 2

 

你可能感兴趣的:(Hibernate)