We’ve got the following repository method
public IList<Foo> GetItems(int fooId, int pageIndex, int pageSize
, string sortField, string sortDir, out int totalItems)
{
// Some code
}
My question is: is it ok to use out in this way. I’m somewhat uncomfortable with out, but can’t come up with a better way to write this as a single call.
I found the answer that I was looking for, though not from the comments. Thank you, though for your help.
It turns out that MVC guru Rob Conery posted some time ago about using a PagedList. It’s elegant pattern and according to the blog, ScottGu has used it in demos. Basically, instead of using
IList<T>andList<T>, you useIPagedList<T>andPagedList<T>.PagedList<T>: List<T>, IPagedList<T>.There’s more code to it, so check out Rob’s blog.
http://blog.wekeroad.com/blog/aspnet-mvc-pagedlistt/