I have just finished creating a custom role provider using LINQ to SQL for data access. One of the functions you need to write for the provider is to remove users from roles;
public void RemoveUsersFromRoles(string[] usernames, string[] rolenames);
Now one approach would be;
- return a list of roles
- iterate for each role and remove that role from all users that have that role
This approach is far from efficient I would like to know if there are better ways to handle this type of problem in LINQ to SQL.
Is there a way to create a select statement in LINQ to SQL that will take a string array for comparison, instead of looping and making N number of selects? Any approach better than what I described above would be much appreciated.
Tables Involved:
User (RecordID, Username)
Role (RecordID, Rolename)
UsersInRole (RoleID,UserID)
Thank You!