I had to come up with a quick way to do paging of a List of objects today as we have been hitting the packet limit on WCF – we could have easily increased the limit, but in my opinion this just masks the error and doesn’t actually fix it.

Anyway, the quick solution that I implemented is roughly as follows:

Change the interface definition on the WCF to allow you to pass in a page number

In your Data Access Layer code, take the page number and do something like:

int skipCount = (pageNumber - 1) * pageSize;

foreach (Signup alpha in webDal.Signups.Skip(skipCount).Take(pageSize))
// Do something else where

As you can see – very simple, no fuss and uses Linq. And in theory it shouldn’t load SQL either thanks to the Skip function.

I believe the RIA Services toolkit is going to have paging in there, but I don’t want to switch everything over right now ;)