As a note, afaik SQL Server doesnt have support for pagination, only TOP
queries (which doesn't take an offset).
In order to achieve pagination, you need to store the result in a
temporary table with an incremented field, and use a WHERE-clause to
limit it. Preferably this should be handled bu NHibernate dialect, but
maybe it isn't.
However, I believe that SetFirstResult has a zero-based index, meaning
.SetFirstResult(0) will not skip any entries. In that case, it should be
able to utilize the TOP keyword if implemented correctly.
Craig van Nieuwkerk wrote:
> 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 SQL generated I can't see
> that there is any paging logic.
>
> What is the most likely errors with this?
>
>
> Craig
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---