Hi,
From the text "The Repository" pattern is a Mediator between the Domain and Data Mapper layers. Cool. So for example, maybe there is a Repository interface and Base Domain Object like so
public interface Repository<DomainT> where DomainT : DomainObject{
DomainT Get(Object id);
}
Then a concrete implementation would be
public class ThreadRepository : Repository<Thread>{
public Order Get(Object id){
return _session.Find(typeof(Thread),id);
}
}
Now my question is this, A Thread can have many posts, like StackOverflow, lets say this Thread has 300 posts. Using the above statement, I will get the Thread Object, and I only want to display lists of 20 items, so I will access the Post Collection property of the Thread object which, due to LazyLoading will fetch all 300, ready for me to handle how I please.
Would it be more efficient to have a method on the Repository called
GetThreadPosts(object threadID, int pageSize, int index);
GetThreadPostCount(object threadID);
Or would the second level cache make this call relatively cheap, as in getting back the 300 posts, preserves my Domain Model.
What if there were 3000 or 30,000 Posts, is the Post Collection property on the Thread Domain Model still valid?
If it is better to have the GetThreadPosts & GetThreadPostCount, does this mean that a property on the Thread object of List is redundant?
Should it be the case that I should have a limit in mind for when a List property on an object is only viable if say the number of items it is likely to have will not exceed a certain number?
Thanks for your time,
Andrew