title: Cannot compare elements of type 'System.Collections.Generic.ICollection`1 Only primitive types, enumeration types and entity types are supported
body: <p>I have written this code</p>
  
  <pre><code>IQueryable&lt;Site&gt; sites = context.MainTable.Include("RelatedTable");
  
  if (!string.IsNullOrEmpty(param1)) {
      sites = sites.Where(s =&gt; s.RelatedTable != null &amp;&amp; s.RelatedTable.Any(p =&gt; p.Name == param1.ToLower() &amp;&amp; p.PolicyType == "primary"));
  }
  
  foreach (string secondaryPolicy in secondaryPolicies)
  {
      sites = sites.Where(s =&gt; s.RelatedTable != null &amp;&amp; s.RelatedTable.Any(p =&gt; p.Name == secondaryPolicy.ToLower() &amp;&amp; p.PolicyType == "secondary"));
  }
  
  return sites.ToList();
  </code></pre>
  
  <p>However at the <code>ToList</code> line I am getting the exception</p>
  
  <blockquote>
    <p>Cannot compare elements of type
    'System.Collections.Generic.ICollection`1[[Project1, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=null]]'. Only primitive types,
    enumeration types and entity types are supported.</p>
  </blockquote>