title: How to propagate a parameter for joins in a ORM
body: <p>This is a <a href="https://stackoverflow.com/questions/29758864/schema-evolution-strategies-preferably-for-net">sequel of a question I asked before</a>. So far the strategy for Schema Evolution problem I'm trying to implement is Slowly changing dimension. The problem that I have now looks as following. Consider the following data model:</p>
  
  <pre><code>class Bar
  {
      int id;
      int param;
  
      double x;
      double y;
  }
  
  class Foo
  {
      int id;
      int param;
  
      string name;
      string description;
  
      collection&lt;Bar&gt; bars;
  }
  
  class Delta
  {
      int id;
      int param;
  
      double rating;
  }
  
  class RootEntity
  {
      int id;
      int param;
  
      collection&lt;Foo&gt; foos;
      collection&lt;Delta&gt; deltas;
  }
  </code></pre>
  
  <p>Note, that all entities have <code>int param</code> attribute. It has the same name but it is not foreign key.
  This is quite simplified model, just as an example. Consider that collections are <strong>huge</strong> and object tree is way more sophisticated. In EntityFramework technology 
  I can do something like:</p>
  
  <pre><code>  class MyDbContext : DbContext
    {
          public DbSet&lt;RootEntity&gt; rootEntities { get; set; }
    }
  </code></pre>
  
  <p>What I want to do is limit the selection by <code>param</code>. That can be as following</p>
  
  <pre><code>dbContext.rootEntities.Where(e =&gt; e.param == some_value);
  </code></pre>
  
  <p>The problem is that only dbContext.rootEntities will be filtered in generated SQL code. The rest (joins with Foo, Bar and Delta) will not be filtered.
  Hence is the question: how to propagate <code>.Where(e => e.param == some_value)</code> to all joins for underlying objects selection?</p>
  
  <p>I'm looking at solutions for EntityFramework or NHibernate.</p>
  
  <p>Thanks.</p>