title: Entity Framework map entity to linq query
body: <p>I am a new in Entity framework (I am using 6.0, but if I need I can update), I am looking for a way to bind  entity to linq query. For example I have:</p>
  
  <pre><code>public class User 
  {
      public string Name {get;set;}
      public WorkPlace Place {get;set;}
      public bool IsAlive{get;set;}
  }
  
  public class WorkPlace
  {
      public string Name {get;set;}
      public bool IsActive {get;set;}
      public Collection&lt;User&gt; Users;
  }
  </code></pre>
  
  <p>Both of them are mapped to tables in a database and I have the <code>OnModelCreating</code>:</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;User&gt;().ToTable(tableName: "users");
      modelBuilder.Entity&lt;WorkPlace&gt;().ToTable(tableName: "workplaces");
  }
  </code></pre>
  
  <p>But I need to use another object (with navigation and lazy loading):</p>
  
  <pre><code>public class CustomUser
  {
      public string Name {get;set;}
      public CustomWorkPlace Place {get;set;}
  }
  
  public class CustomWorkPlace
  {
      public string Name {get;set;}
      public Collection&lt;CustomUser&gt; Users;
  }
  
  someBuilder.Entity&lt;CustomUser&gt;().ToLinq(cntx =&gt; cntx.Set&lt;User&gt;().Where(user =&gt; user.IsAlive)).MapProperties(); 
  // the way of mapping properties is not important
  someBuilder.Entity&lt;CustomWorkPlace&gt;().ToLinq(cntx =&gt; cntx.Set&lt;WorkPlace&gt;().Where(place =&gt; plase.IsActive)).MapProperties()
  </code></pre>
  
  <p>And the most interesting thing of that is going through the navigation, when I get company of an user, I must not get a company which is not active, and the same for a company - I must not get any <code>CustomUser</code> which is mapped to not alive User.</p>
  
  <p>Thanks a lot</p>