title: Get a list of elements by their ID in entity framework
body: <p>How can I get all elements that are in another list by ID?
  I have List roles; I'd like to get all roles from the database that are in this list by their Id.</p>
  <p>I'm using code-first.</p>
  <p>I did this and it threw an error:</p>
  <pre class="lang-cs prettyprint-override"><code>var roles = db.Roles.Where(r =&gt; user.Roles.Any(ur =&gt; ur.RoleId == r.RoleId));
  </code></pre>
  <p><code>RoleId</code> is of type int.</p>
  <p>Error:</p>
  <blockquote>
  <p>Unable to create a constant value of type 'SampleMVC.Domain.Role'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.</p>
  </blockquote>