This project is read-only.

Exposing the paging information as a PagedCollection class

May 25, 2010 at 11:15 PM

I was thinking about the current model where all the collections are returned as an IEnumerable<Xxxx> and how to expose the paging information. One thing I thought might help is to implement a new class called PagedCollection<T> : IEnumerable<T>. in addition to the standard IEnumerable<> semantic, this class would expose the paging information (total, pagenum, pagesize), which is currently kept in the Response base class.

In fact, since the Response class and its descendants need to be public in SL for the JSON serialization to work, we might as well just use the PagedCollection<T> as a base class instead of Response.



May 26, 2010 at 2:45 AM

I like this. I was thinking an interface like:

public interface IPagedList<T> : IEnumerable<T>
    int TotalItems { get; set; }
    int CurrentPage { get; set; }
    int PageSize { get; set; }
I'll do a spike to see how it works as a base class.

May 26, 2010 at 8:01 PM

I just checked in the changes implementing this interface and returning it where applicable. I ended up leaving the Response classes as is and just wrapping them in an IPagedList just before being returned to the caller. Let me know if you have any feedback. My next work item is working out the interfaces for the client classes.