title: How can I add a where clause to an in included entity in EF?
body: <p>I have three tables</p>
  
  <ul>
  <li>Person Table (Generic person table)</li>
  <li>Customer Table (every customer is a person)</li>
  <li>Address Table (every customer has an address)</li>
  </ul>
  
  <p>I need to query the database from entity framework for a match on the person's name and city, state. This is what I have but it doesn't work unless I remove the state and city from the where clause</p>
  
  <pre><code>var customer = db.tbl_Person
      .Include(t =&gt; t.tbl_Customer.tbl_Address)
      .Where(t =&gt; t.VendorID == person.VendorID &amp;&amp;
                  t.FirstName == person.FirstName &amp;&amp;
                  t.LastName == person.LastName &amp;&amp;
                  t.tbl_Customer.tbl_Address.State == address.State &amp;&amp;
                  t.tbl_Customer.tbl_Address.City == address.City).ToList();
  </code></pre>
  
  <p>Any help would be appreciate - I'm still fairly new to EF. As stated in my comments below, the error I get is</p>
  
  <blockquote>
    <p>Additional information: Unable to cast object of type
    'System.Linq.Expressions.FieldExpression' to type
    'System.Linq.Expressions.ParameterExpression'.</p>
  </blockquote>