title: LINQ To Entity - With Many to Many Relationship - VB.NET
body: <p>I have the following tables in SQL:</p>
  
  <p>Users (UserID, Email)
  Roles (RoleID, RoleName)
  UsersInRoles (UserID, RoleID)</p>
  
  <p>I want to bring back a list of all Roles and a field which says whether that role has been assigned to a particular user.</p>
  
  <p>In SQL I would do this using the below query:</p>
  
  <pre><code>SELECT R.RoleID, RoleName, CASE WHEN ISNULL(UIR.UserID, 0) = 0 THEN 0 ELSE 1 END
  FROM Roles R
  LEFT JOIN UsersInRoles UIR ON R.RoleID = UIR.RoleID AND UserID = 2
  </code></pre>
  
  <p>My entity model hides the UsersInRoles table and instead creates a navigation property in each of the Users and Roles entities to link the two.</p>
  
  <p>I'm trying to write a similar LINQ to Entity query but have not been able to.</p>
  
  <p>Can you help?</p>