asp.net mvc 5

时间:2016-08-03 14:00:07

标签: asp.net-mvc-5 linq-to-entities

大家好我的问题是关于asp.net mvc5中的多对多关系。我有一个表UsersProjects,它们具有多对多的关系,并且两者在其导航属性中相互拥有。我想获取由MaanagerUser(a)添加的那些项目(y)的测试者/开发人员/用户(x)

                    return View(db.Users.ToList().Where(u => u.Projects.Select().Where(s => s.Users.Contains(usr))));

usr是添加了许多projects的管理员,我希望看到这些项目的testersdevelopers

以下是表格 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 | +--------------------------+ 希望我解释我的问题谢谢!

0 个答案:

没有答案