Linq th Join子句中某个表达式的类型不正确。对组联接的调用中的类型推断失败

Linq th Join子句中某个表达式的类型不正确。对组联接的调用中的类型推断失败,linq,linq-to-sql,Linq,Linq To Sql,请查看我的Linq查询并提出修复建议。第二个连接给出错误 var result = (from e in _DB_Goal_Allocation.Employees.Where(x => x.Active == 1 && x.Branch_Number == ddlBranch) join j in _DB_Goal_Allocation.Employees_JobTitleGroupLOBs.Where(y =>

请查看我的Linq查询并提出修复建议。第二个连接给出错误

 var result = (from e in _DB_Goal_Allocation.Employees.Where(x => x.Active == 1 && x.Branch_Number == ddlBranch)
                          join j in _DB_Goal_Allocation.Employees_JobTitleGroupLOBs.Where(y => Job_Group.Contains(y.JobGroup)) on e.Title equals j.JobTitle
                          join g in _DB_Goal_Allocation.Goal_Allocation_Employees.Where(ga => ga.Year == ddlYear)
                          on new{ e.Branch_Number, e.EmployeeID } equals new { Branch_Number = g.BranchNumber, EmployeeID = g.EmployeeID } into emp
                          from t in emp.DefaultIfEmpty()
                          select e.FirstName + " " + e.LastName as EmployeeName).ToList();

那么所涉及的类型是什么(例如分支机构编号、分支机构编号、雇员ID、雇员ID)?如果没有更多信息,我们将无法帮助您…Branch_编号是可为空的int和BranchNumber int,并且两个EmployeeID都是int,这就是问题所在。您需要将BranchNumber强制转换为可为null的
。类型必须与连接完全匹配。在你问之前,我甚至没有想到可为null的东西。谢谢!!成功了。