Type Inference failed in a call to 'join' on nullable and non-nullable int

后端 未结 6 1882
半阙折子戏
半阙折子戏 2021-01-12 02:20

In my Linq, I am trying to make an inner join to a nullable field. Employee and Department have a relation, Department may have an EmployeeID or may have a null. So what wou

6条回答
  •  太阳男子
    2021-01-12 02:52

    To compare Int? and Int, append .Value to the nullable property:

    var result = from emp in employees
                 join dept in departments
                 on new { Source = emp.EmployeeID }
                 equals new { Source = dept.EmployeeID.Value };
    

提交回复
热议问题