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

后端 未结 6 1921
半阙折子戏
半阙折子戏 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:47

    In my scenario I had this error on a join using multiple columns. The property names were different and one of them was also nullable. All I did was creating a name to those properties and adding the ".Value" on the nullable value so the LINQ Join could correctly associate those properties.

    var query = from y in Context.Table1
            join y in Context.Table2 on new { Field1 = x.Field1.Value, Field2 = x.Field2 }
            equals new { Field1 = y.Field1DiffName, Field2 = y.Field2 }
    

    I hope it helps whoever is facing this issue.

提交回复
热议问题