Get PageCount through filtering decorators
<p>I would like to add paging functionality to a website (running ASP.NET MVC).
A heavy use of decorators is making it difficult for me to implement a GetPageCount method on a class.</p>

<p>Currently i have something like this:</p>

<pre><code>class ProductRepository {
    private DataContext _db;

    public IQueryable&lt;Product&gt; GetProducts(){
        return _db.Products();
    }
}

class ProductService {
    private ProductRepository _repository;

    public IEnumerable&lt;Product&gt; GetProducts(int categoryId) {
        return _repository.GetProducts().Where(p =&gt; p.CatId == categoryId).ToList();
    }

    // This I would like to add
    public int GetPageCount(int categoryId, int pageSize) {
        int count = _repository.GetProducts().Where(p =&gt; p.CategoryId == categoryId).Count()
        return (count + pageSize - 1) / pageSize;
    }
}

class ActiveProductServiceDecorator {
   private ProductService _service;

   public IEnumerable&lt;Product&gt; GetProducts(int categoryId) {
       return _service.GetProducts(categoryId).Where(p =&gt; p.Active).ToList();
   }

    // How do I implement this to only count active products?
    public int GetPageCount(int categoryId, int pageSize) {
        return _service.GetPageCount(categoryId, pageSize);
    }
}
</code></pre>
