title: How to filter ICollection<ApplicationUser> on a Role in ASP.NET MVC 5's Identity
body: <p>I have added 3 roles:</p>
  
  <ol>
  <li>Administrators</li>
  <li>Staff</li>
  <li>Registered</li>
  </ol>
  
  <p>Now I want to display a list of all <code>Registered</code> users. 
  I'm afraid I'm not getting the Identity system, because I am trying to do something like this:</p>
  
  <p><strong>Spoiler Alert: not working code</strong></p>
  
  <pre><code>var listOfNames = _unitOfWork.UserRepository.All()
                                              .Where(u =&gt; u.Roles.Contains("Registered"))
                                              .ToList();
  </code></pre>
  
  <p>This obviously does not work, so I went searching for an answer. Unfortunately I did not get any. The closest I could find was a post by Scott Allen who mentioned <code>IUserRoleStore</code> which has the following implementations:</p>
  
  <ul>
  <li>Add a user to a role</li>
  <li>Get all the roles for a user</li>
  <li>Check is a user is in a specific role</li>
  <li>Remove a user from a role</li>
  </ul>
  
  <p>But still, not getting it :/</p>
  
  <p>I have also tried the methods in <a href="https://stackoverflow.com/questions/21265031/how-to-retrieve-users-with-a-specific-role-via-linq-in-aspnet-identity">this Question</a>, but <code>Roles.Select(r =&gt; r.Name).Contains("client")</code> does not work because the Name property can't be found?</p>
  
  <p>How can I get this list of ApplicationUser objects?</p>
  
  <h2>Update</h2>
  
  <hr>
  
  <p>Sean's answer helped me to dig a little deeper. I'm not sure this is the best way, but it works for my needs.</p>
  
  <pre><code>var users = context.Users;
  var roleUsers = context.Roles.Single(one =&gt; one.Name == "Registered").Users;
  
  names = (from r in roleUsers
  join u in users on r.UserId equals u.Id
  select u.UserName).ToList();
  </code></pre>
  
  <p>If this is inefficient, I'd love to hear why and how I can improve it.</p>