title: LINQ query - Multiple where with multiple sub queries based on int array
body: <p>I have a sql query that performs the type of select I'm after:</p>
  
  <pre><code>select * from Products p where p.ProductId in (
      select distinct ProductId from ProductFacets 
      where ProductId in (select ProductId from ProductFacets where FacetTypeId = 1)
      and ProductId in (select ProductId from ProductFacets where FacetTypeId = 4)
  )
  </code></pre>
  
  <p>There can be multiple FacetTypeIds passed into this query. </p>
  
  <p>This query is constructed in a method based on a parameter argument of type int[]. </p>
  
  <pre><code>public IEnumerable&lt;Product&gt; GetProductsByFacetTypes(string productTypeSysName, int[] facetTypeIds)
  </code></pre>
  
  <p>I'm trying to work out how to achieve this in LINQ. So far I've come up with something like this:</p>
  
  <pre><code>var products = from p in sc.Products
  where p.ProductType.SysName == productTypeSysName
  where p.FacetTypes.Any(x =&gt; x.FacetTypeId == 1)
  where p.FacetTypes.Any(x =&gt; x.FacetTypeId == 4)
  select p;
  </code></pre>
  
  <p>This returns the correct result set. </p>
  
  <p>However I'm not sure how I can build this query using the int[] facetTypeIds parameter. </p>
  
  <p>EDIT:</p>
  
  <p>ProductFacets contains the following data:</p>
  
  <pre><code>ProductId, FacetTypeId
  1, 1
  1, 2
  2, 1
  2, 3
  3, 4
  3, 5
  4, 1
  4, 2
  </code></pre>
  
  <p>As an example, I'd like to be able to select only Products which have a FacetTypeId of 1 AND 2. 
  The result set should contain ProductIds 1 and 4</p>