I want to do paging outside of my Repository, but the Repository returns IList. Since I don't want to pull data unnecessarily, and don't want to create specific Paging methods in my Repositories, Is there any way to filter records by page in the Where extension method?
I want to do something like:
var myRecords = ProductRepo.Get( p => p.Name.StartsWith("Pepsi") &&
p.Row_Number() > 9 &&
p.Row_Number() < 21);
The Get repository code (doesn't handle row number of course):
public IList<Product> Get( Expression<Func<Product, bool>> filter = null)
{
if( filter == null)
return _dc.Products.ToList<Product>();
else
return _dc.Products.Where(filter).ToList<Product>();
}