My User Class is given below
public class User
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string UserName { get; set; }
public Roles Role { get; set; }
public List<Role> Roles { get; set; }
}
My Role class is given below
public class Role
{
public int Id { get; set; }
public string RoleName { get; set; }
}
My enum is given below
public enum Roles
{
Admin,
Guest,
Accountant
}
Getting error(Cannot compare string to enum) when compare string with enum values with the code given below
if(User.Roles.Where(m => _roles.Contains(m.RoleName)).ToList()))
{
}
=>* here m.RoleName getting error(Cannot compare string to enum)