Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing IPagedList<T> on my models using NHibernate
    primarykey
    data
    text
    <p>I have found when using NHibernate and creating a one to many relationship on an object that when the many grows very large it can slow down dramatically. Now I do have methods in my repository for collecting a paged IList of that type, however I would prefer to have these methods on the model as well because that is often where other developers will look first to gather the list of child objects.</p> <p>e.g.</p> <p>RecipientList.Recipients will return every recipient in the list.</p> <p>I would like to implement a way to add paging on all of my oen to many relationships in my models using preferably an interface but really anything that won't force a typed relationship onto the model. For example it would be nice to have the following interface:</p> <pre><code>public interface IPagedList&lt;T&gt; : IList&lt;T&gt; { int Count { get; } IList&lt;T&gt; GetPagedList(int pageNo, int pageSize); IList&lt;T&gt; GetAll(); } </code></pre> <p>Then being able to use it in code...</p> <pre><code>IList&lt;Recipient&gt; recipients = RecipientList.Recipients.GetPagedList(1, 400); </code></pre> <p>I have been trying to think of ways to do this without giving the model any awareness of the paging but I'm hitting my head against a brick wall at the moment.</p> <p>Is there anyway I can implement the interface in a similar way that NHibernate does for IList and lazyloading currently? I don't have enough knowledge of NHibernate to know.</p> <p>Is implementing this even a good idea? Your thoughts would be appreciated as being the only .NET developer in house I have no-one to bounce ideas off.</p> <p><em>UPDATE</em></p> <p>The post below has pointed me to the custom-collection attribute of NHibernate, which would work nicely. However I am unsure what the best way is to go around this, I have tried to inherit from PersistentGenericBag so that it has the same basic functionality of IList without much work, however I am unsure how to gather a list of objects based on the ISessionImplementor. I need to know how to either:</p> <ul> <li>Get some sort of ICriteria detail for the current IList that I am to be populating</li> <li>Get the mapping details for the particular property associated with the IList so I can create my own ICriteria. </li> </ul> <p>However I am unsure if I can do either of the above?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload