brockallen / BrockAllen.MembershipReboot

MembershipReboot is a user identity management and authentication library.
Other
742 stars 238 forks source link

Access account from particular claim #591

Closed zebamba closed 8 years ago

zebamba commented 8 years ago

Is it possible to get a list of account from same claim?

On my application location is a claim on Users, I need to get a list of users that belongs to same location / contains particular claim.

Thank you.

brockallen commented 8 years ago

There's a IQueryable property on the UserAccountService (if your DB layer supports it), or you can hit the DB directly via your DB framework.

zebamba commented 8 years ago

Is this method on line 143?

 public virtual IUserAccountQuery Query 

Thank you.

brockallen commented 8 years ago

Yes.

zebamba commented 8 years ago

You can close the question. Thank you.

apuchkov commented 8 years ago

Here's an example how to find accounts by particular claim:

public IEnumerable<UserAccountQueryResult> GetUsersByClaim(string claimType, string claimValue)
{
    return userAccountService.Query.Query(
        users =>
            users.Where(user => user.ClaimCollection.Any(claim => claim.Type == claimType && claim.Value == claimValue)));
}