Say I have the following database:
Users
-------
UserId (PK)
UserName
Roles
-----
RoleId (PK)
RoleName
UserRoles
---------
UserId (PK)
RoleId (PK)
Users 1-M UserRoles M-1 Roles
Using LinqToSQL, I want to return the following set:
[User1], [Role1, Role2, Role3]
[User2], [Role2, Role3]
[User3], []
Etc…
What is the most efficient way to create this LinqToSql Query?
In addition, if I want to create a filter to return only users that have Role1, what would that entail?
Thx.
Define “efficient”. But otherwise…
And filtering users by
RoleID:Or by some other
Roleattribute, say,Name:Combining it all together: