title: Get all users with a given claim
body: <p>I'm working on an aspnet core 1.0 project, I've recently understood what claims are and how to use them to achieve policy based authorization.</p>
  
  <h2>What I'm trying to acheive:</h2>
  
  <p>I want to get all users that are authorized with a given policy (i.e. users that have a given claim, let's say <code>Claim {Type = "CanReceiveXReport", Value = True}</code>)</p>
  
  <p>The code I'd expect to do this is something like:</p>
  
  <pre><code>public static IQueryable&lt;User&gt; WithClaim(this IQueryable&lt;User&gt; users, string claimName) =&gt;
      users
          .Include(u=&gt; u.Claims)
          .Where(u=&gt; u.Claims.Any(c=&gt; c.ClaimType == claimName));
  </code></pre>
  
  <h2>The problem:</h2>
  
  <p>When I run the above code, for all users, <code>user.Claims</code> is always empty. I've also tried to materialize the query by adding a <code>ToList()</code> after the <code>Include()</code> with no success.</p>
  
  <hr>
  
  <p>When I realized this wasn't working I expected there to be a <code>ClaimsManager&lt;T&gt;</code> of some sort to do this kind of operations.</p>
  
  <p>All the apis and <a href="https://stackoverflow.com/a/40491035/2226079">answers</a> I've found are focused on getting claims for a single user.</p>
  
  <p>I know I could do something like what <a href="https://stackoverflow.com/a/26389535/2226079">this answer</a> but I rather not do that, I want that query to be run in the database.</p>
  
  <p>I imagine it's possible to create a stored procedure, but I'd rather mantain my domain logic in my app.</p>
  
  <h2>Versions:</h2>
  
  <p>(That I think are relevant)</p>
  
  <pre><code>{
      "Microsoft.AspNetCore.Identity": "1.0.0",
      "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
      "Microsoft.EntityFrameworkCore.Relational": "1.0.0",
      "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
      "Microsoft.NETCore.App": "1.0.0"
  }
  </code></pre>