title: LINQ to Entities - query across relationships and filter
body: <p>I am having a very difficult time with querying a set of related entities with LINQ and Lambda expressions.</p>
  
  <p>I have four entities that are related as such ...</p>
  
  <p><strong>Vehicles</strong> 1:n <strong>VehicleTypes</strong> n:1 <strong>Prices</strong> 1:n <strong>CustomerTypes</strong></p>
  
  <p>I am trying to obtain a list of Prices for a given Vehicle and CustomerType. For example I would like to obtain all the Prices for a Ford Mustang (VehicleTypeId = 2). In those Prices I would like included the CustomerType (Government, Commercial, Retail) that the Price pertains to.</p>
  
  <p>I thought I might be able to do the following ...</p>
  
  <pre><code>Prices.Include(p =&gt; p.VehicleTypes)
        .Include(p =&gt; p.CustomerTypes)
        .Where(p =&gt; p.VehicleTypes.Vehicles.Select(v =&gt; v.Id == 2)
  </code></pre>
  
  <p>However I get this error ...</p>
  
  <pre><code>Cannot implicitly convert type 'System.Collections.Generic.IEnumerable&lt;bool&gt;' to 'bool'
  </code></pre>
  
  <p>I cannot seem to create a Where condition where I can filter the Id of the Vehicle to be purchased yet also include the CustomerType in the results.</p>
  
  <p>EDIT: Just wanted to note that I have included <code>using System.Data.Entity</code> so I have access to the type safe Include extension</p>