title: Entity Framework - Dynamic Filters on child/parent entities
body: <p>I have a question that I hope someone might be able to help me out with. I'm using Entity Framework 6 with Dynamic Filters to do stuff like filtering out soft deleted entities like so: </p>
  
  <pre><code>modelBuilder.Filter("SoftDeleteEntity", (ISoftDeleteEntity d) =&gt; d.DateDeleted, null);
  </code></pre>
  
  <p>However - I have a need to filter the entire graph when querying. So let's say that I have: </p>
  
  <pre><code>public class Company
  {
      public int CompanyId { get; set; }
      public string Name { get; set; }
      public bool Active { get; set; }
  
      public List&lt;Product&gt; Products { get; set; }
  }
  
  public class Product
  {
      public int ProductId { get; set; }
      public string Name { get; set; }
      public decimal Price { get; set; }
      public Company Company { get; set; }
  }
  </code></pre>
  
  <p>It's easy for me to filter out the in-active companies by creating a new filter: </p>
  
  <pre><code>modelBuilder.Filter("InactiveCompaniesFilter", (Company c) =&gt; c.Active, true);
  </code></pre>
  
  <p>However - if I now query my Products then I'll still get all Products belonging to inactive companies. I can of course avoid this be doing this everywhere I query my products: </p>
  
  <pre><code>_dbContext.Products.Where(i =&gt; i.Company.Active)
  </code></pre>
  
  <p>But as the application grows this becomes a major pain. 
  So the question is - can I create an Entity Framework filter that works across child/parent entities?</p>
  
  <p>Thanks a lot :) </p>