title: Subquery in LINQ to Entities
body: <p>I have a working query in LINQ to SQL. I need to convert it into LINQ to Entities. </p>
  
  <pre><code>(from pr in Products
  join c in Categories on pr.CategoryID equals c.CategoryID
  join b in Colors on pr.ColorID equals b.ColorID
  select new{
  ProductID = pr.ProductID,
  Manufacturer = pr.Manufacturer.Name,
  Model = v.Model.ModelName,
  Category = c.Name,
  Photos = from p in Photos where pr.ProductID == p.ProductID select p
  }).FirstOrDefault()
  </code></pre>
  
  <p>When I use it as it is I get an error: </p>
  
  <blockquote>
    <p>Unable to create a constant value of type Only primitive types ('such
    as Int32, String, and Guid') are supported in this context.</p>
  </blockquote>
  
  <p>The problem is in this part:</p>
  
  <pre><code>Photos = from p in Photos where pr.ProductID == p.ProductID select p
  </code></pre>