我想列出包含一个特定角色的所有用户。
这是我要做的事情:
foreach (var user in db.Users.Where(x => x.Roles.Select(y => y.Role).Contains("Admin")).ToList())
{}
但这是错误的结果:
Error 2 'System.Collections.Generic.IEnumerable<Microsoft.AspNet.Identity.EntityFramework.IdentityRole>' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.Queryable.Contains<TSource>(System.Linq.IQueryable<TSource>, TSource)' has some invalid arguments
我怎样才能使这个工作?
FIX
foreach (var user in db.Users.Where(x => x.Roles.Select(y => y.Role.Name == "Admin").FirstOrDefault()).ToList())