Paging over a lazy-loaded collection with NHibernate

僤鯓⒐⒋嵵緔 提交于 2019-11-30 06:50:32

I'm pretty sure (reading the comments) that he's talking about the CreateFilter of ISession.

You can do paging like this (from the docs 13.13):

Collections are pageable by using the IQuery interface with a filter:

IQuery q = s.CreateFilter( collection, "" ); // the trivial filter
q.setMaxResults(PageSize); 
q.setFirstResult(PageSize * pageNumber); 
IList page = q.List();

Or (from the docs 17.1.4):

s.CreateFilter( lazyCollection, "").SetFirstResult(0).SetMaxResults(10).List();

That's is not as smooth as using the System.Linq methods. I guess they'll join the syntax some time too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!