Linq中join多字段匹配
错误示范:
var projectSubmitInfos = (from project in db.T_PM_Project join member in db.T_PM_Member on project.ProjectID equals member.ProjectID join user in db.T_Sys_UserInfo on member.UserID equals user.UserID join task in taskSummary on new {member.UserID, member.ProjectID} equals new {task.UserId, task.ProjectId} select new XXX { });
正确示范:
var projectSubmitInfos = (from project in db.T_PM_Project join member in db.T_PM_Member on project.ProjectID equals member.ProjectID join user in db.T_Sys_UserInfo on member.UserID equals user.UserID join task in taskSummary on new {UserId = member.UserID, ProjectId = member.ProjectID} equals new {task.UserId, task.ProjectId}
select new XXX
{
});
两者区别在于on条件中,第一个条件new的对象要加入字段名