大家好我的问题是关于asp.net mvc5中的多对多关系。我有一个表Users
和Projects
,它们具有多对多的关系,并且两者在其导航属性中相互拥有。我想获取由MaanagerUser(a)添加的那些项目(y)的测试者/开发人员/用户(x)
return View(db.Users.ToList().Where(u => u.Projects.Select().Where(s => s.Users.Contains(usr))));
usr
是添加了许多projects
的管理员,我希望看到这些项目的testers
和developers
以下是表格
Users
+--------------------------------------+
| UserId | UserName | Role |
+---------------------------------------+
| 1 | Drake | Manager |
+---------------------------------------+
| 2 | John | Tester |
+---------------------------------------+
| 3 | Smith |Developer|
+---------------------------------------+
Projects
+-----------------------------+
| ProjectId | ProjectsName |
+------------------------------+
| 1 | Project 1 |
+------------------------------+
| 2 | Project 2 |
+------------------------------+
User_Projects
+-------------------------+
| ProjectId | UserID |
+--------------------------+
| 1 | 1 |
+--------------------------+
| 1 | 2 |
+--------------------------+
| 1 | 3 |
+--------------------------+
| 2 | 4 |
+--------------------------+
| 2 | 3 |
+--------------------------+
希望我解释我的问题谢谢!