我正在尝试让具有角色Admin且没有被锁定或阻止的用户列表。你能帮我吗?
(_userManager.GetUsersInRoleAsync("Admin")).Result.Where((_userManager.Users.Where(u => u.LockoutEnabled == false)));
(_userManager.GetUsersInRoleAsync("Admin")).Result.Where((_userManager.Users.Where(u => u.UserAccountIsBlocked == UserAccountIsBlocked.No)));
答案 0 :(得分:0)
我想您定义了porperty UserAccountIsBlocked。所以:
var1 = ''.join(data[0])
var2 = ''.join(data[1])
答案 1 :(得分:0)
要查询User Role
和其他属性,可以尝试使用linq,如下所示:
var query = from user in _context.Users
join userRole in _context.UserRoles on user.Id equals userRole.UserId
join role in _context.Roles on userRole.RoleId equals role.Id
where user.LockoutEnabled == false
//&& user.UserAccountIsBlocked == UserAccountIsBlocked.No
&& role.NormalizedName == "Admin"
select user;
var users = query.ToList();
您可以根据业务逻辑添加其他查询条件。