select id,empName,phone from employees (员工表)
select id,projectid,employeeid,projectRote from project_employee (项目与员工的关系表,projectRote 字段是员工在项目角色)
需要实现如下效果:
传入一个项目ID(16),返回该项目的参与者和在项目中的角色
select empName,phone,projectname,projectrote from projects p,employees e,project_employee pe
where pe.projectid=16 and e.id=pe.employeeid and p.id=16
请问这个用LINQ怎么实现这个语句?谢谢了!
2 个解决方案
#1
有没有外键,有外键直接从 project_employee 入手
var query = from pe in project_employee
where pe.id == 16
select new { pe.employees.empName, pe.projectRote };
#2
var query=from p in projects join e in employees join pe in project_employee on 条件
where pe.id == 16
select new
{
e.empName
...
};
where pe.id == 16
select new
{
e.empName
...
};
#1
有没有外键,有外键直接从 project_employee 入手
var query = from pe in project_employee
where pe.id == 16
select new { pe.employees.empName, pe.projectRote };
#2
var query=from p in projects join e in employees join pe in project_employee on 条件
where pe.id == 16
select new
{
e.empName
...
};
where pe.id == 16
select new
{
e.empName
...
};