我将UserRole扩展如下:
public class ApplicationUserRole : IdentityUserRole
{
public ApplicationUserRole() : base() { }
public int? ModelPk { get; set; }
public MasterModelType MasterModelType { get; set; }
}
现在,我想检查用户是否在特定ModelPk上具有特定角色。 IE浏览器。检查userA是否在project43上有roleB。
答案 0 :(得分:2)
不完全确定,但也许尝试使用lambda?也许是这样的:
private void testMethod()
{
IdentityRole ident = new IdentityRole();
var Role = ident.Users.FirstOrDefault(a => Convert.ToInt32(a.RoleId) == ModelPk);
}
更多细节可能会有所帮助。