I have a drop down list box which lists roles. I want to get the list of users having that role. I mean list of users that are in \"Administrator\" role or \"CanEdit\" role.
Not an expert, but ...
There seemed to be no built in funcionality for this in Identity and I could not get it work from built in Roles also (it seems to not work with claims based Identity).
So I ended up doing something like this:
var users = context.Users
.Where(x => x.Roles.Select(y => y.Id).Contains(roleId))
.ToList();
x.Roles.Select(y => y.Id) gets a list of all role ids for user x.Contains(roleId) checks if this list of ids contains necessary roleId