I am using nHibernate and trying to implement some paging. If I run this code
IList list = session.CreateQuery("FROM Author").List();
it returns 8 records. If I run this code though
IList list = session.CreateQuery("FROM Author") .SetFirstResult(1).SetMaxResults(5).List();
it returns 0 records. When I look at the generated SQL, I don’t see that there is swap logic.
What are the most likely mistakes with this?
I'm not sure about NHibernate, but in Java, the result index is based on 0. Try calling .SetFirstResult (0) instead of .SetFirstResult (1), otherwise, if there is only one row, it will return 0 results. It looks like you have 8 rows, so I don’t know why you won’t get any results anyway.
, , , 0 .
SQL, MSSQL Server LIMIT OFFSET, . (n.b. , SQL Server 2005 , LIMIT OFFSET). , SQL 2000 , , .
, , , . , , . -, SetFirstResult/SetMaxResults .
, Dialect Connection Provider web.config app.config
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
Source: https://habr.com/ru/post/1704870/More articles:Lazy Download at NHibernate - nhibernateJquery Asp.net selectable row table - jqueryunix-fork-monitor-child-progress - c ++Strange annotation warning SAL - c ++Clojure graphic calculator. "-" always returns 0, and "/" always returns 1 - javaHow to prevent application timeout? - androidRails: finding multiple tables from a single query - ruby-on-railsВ С# есть ли способ последовательно получать выделенное текстовое содержимое окна, сфокусированного в данный момент? - c#Tools for receiving notifications of creation in Skype group chat - build-processTesting WCF Web Service with QTP - automated-testsAll Articles