title: Entity Framework Core- Use Expression Tree With Interface As Parameter
body: <p>I will really appreciate some help with following scenario.
  I have the following classes:</p>
  
  <pre><code>public class Product : IHasPrice
  {
      public string Title { get; set; }
      public int Price { get; set; }
      public string CustomerId { get; set; }
  
  }
  
  public interface IHasPrice
  {
      int Price { get; set; }
  }
  
  public class ProductProvider
  {
      public ProductProvider()
      {
      }
  
      public IEnumerable&lt;Product&gt; GetByCustomer(string customerId, Expression&lt;Func&lt;IHasPrice, bool&gt;&gt; predicate = null)
      {
          using (var db = new ApplicationDbContext())
          {
              var queryable = db.Products.Where(p =&gt; p.CustomerId == customerId);
              if (predicate != null)
              {
                  return queryable.Where(predicate).ToList();
              }
              else
              {
                  return queryable.ToList();
              }
          }
      }
  }
  
  </code></pre>
  
  <p>I want to enable to use the <code>ProductProvider</code> in a way where you can only select by customer, but you can also filter on the price in any way you like (and only on the price). 
  This example doesn't work since <code>queryable.Where</code> expects parameter with typeof <code>Expression(Func(Product, bool))</code>. Is there a way to do it or I must fetch the data to memory before the filtering of the price?</p>