This question is locked. New answers and comments are not allowed.
Hi all,
I've a database with the following tables:
I've a database with the following tables:
- Person
- Role
- Person_Role
I can get Roles out of a Person and vice versa. Works okay.
Now I have to add a function that can add a Person into a Role (as needed bij the MembershipProvider).
So, how can I do this within LINQ?
Since the OpenAccess Model doesn't show the intermediate table, which I believe it the right approach, I still don't get how to do this.
I came up with this code, but I doubt if that is the right way:
public
void
AddPersonToRole(
string
rolename,
string
username)
{
try
{
Person p = GetPerson(username);
Role r = GetRole(rolename);
p.Roles.Add(r);
context.SaveChanges();
}
catch
(Exception ex)
{
throw
ex;
}
}
How should I deal with this intermediate thing? (m:m)
Thanks,
Daniel