Paging over a lazy-loaded collection with NHibernate

后端 未结 1 1480
别那么骄傲
别那么骄傲 2020-12-30 06:14

I read this article where Ayende states NHibernate can (compared to EF 4):

  • Collection with lazy=”extra” – Lazy extra means that NHibernate ada
相关标签:
1条回答
  • 2020-12-30 06:40

    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.

    0 讨论(0)
提交回复
热议问题