title: Entity Framework: Unable to create a constant value of type 'System.Collections.Generic.IList`1'
body: <p>This has caused me no end of problems today.  I have this simple query</p>
  
  <pre><code>var result =
      DataContext.Accommodations.Where(a =&gt; 
          (criteria.MinPrice == null || a.AccommodationRates.Any(r =&gt; r.From &gt;= criteria.MinPrice)) &amp;&amp;
          (criteria.MaxPrice == null || a.AccommodationRates.Any(r =&gt; r.To &lt;= criteria.MaxPrice)) &amp;&amp;
          (criteria.Locations == null || criteria.Locations.Count == 0 || a.AccommodationPlaceJoins.Any(j =&gt; criteria.Locations.Contains(j.Place.PlaceName)))
  );
  </code></pre>
  
  <p>The last line of this query is causing me problems</p>
  
  <pre><code>(criteria.Locations == null ||
   criteria.Locations.Count == 0 ||
   a.AccommodationPlaceJoins.Any(j =&gt; criteria.Locations.Contains(j.Place.PlaceName)))
  </code></pre>
  
  <p>The error it gives is </p>
  
  <blockquote>
    <p>Unable to create a constant value of type
    'System.Collections.Generic.IList`1'. Only primitive types ('such as
    Int32, String, and Guid') are supported in this context.</p>
  </blockquote>
  
  <p>I'm not even trying to create a list.  All I'm trying to do here is bring back accommodations which are associated to a place (where the place name in the Place table which is linked to the Accommodation table via the AccommodationPlaceJoin table) is equal to any one of the place names in criteria.Locations (which is of type IList).</p>
  
  <p>I've tried changing this line to this, but it didn't work.</p>
  
  <pre><code>(criteria.Locations == null ||
   criteria.Locations.Count == 0 ||
   a.AccommodationPlaceJoins.Any(j =&gt; criteria.Locations.Any(l =&gt; l == j.Place.PlaceName)))
  </code></pre>