I have a problem with this piece of code, when I do my intersect method everything works fine.
When I do the count on my intersection before the foreach I have 1.
After the foreach, if do the count again after the foreach I have 0, why is this happening? It should always be 1...
var matchedRoles = roles.Intersect(user.Roles);
int before = matchedRoles.Count();
foreach (var matchedRole in matchedRoles)
{
user.Roles.Remove(matchedRole);
}
int after = matchedRoles.Count();
if (matchedRoles.Any())
{
accountRepository.Update(user);
}