I am having two list of Users class i.e UsersExisting, UsersToUpdate. Class Structure is like below.
public class Users
{
public string Name{get;set}
public Roles[] AvailableRoles{get;set}
}
class Roles
{
public int Serial{get;set}
public string Name{get;set}
public bool IsActive{get;set}
}
I have to check whether UsersToUpdate has already all the Role details of UsersExisting.
Eg. This is the list
UsersExisting.AvailableRoles={{1,"admin",true},{2,"hr",false},{3,"it",true}};
UsersToUpdate.AvailableRoles={{1,"admin",true},{2,"hr",false},{3,"it",true},{4,"finance",false}};
How to do this with LINQ.
I am doing like this.
bool isUsersUpdated = !UsersExisting.AvailableRoles
.Except(UsersToUpdate.AvailableRoles).Any();
This is throwing error.