LINQ - 'The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin'.'

.net, c#, linq

Solution

The types of the properties used with the equals expression must match. So for example is `Table1.SomeID` is `Int32` and `Table2.SomeID` is `Nullable<Int32>`, then they don't match.

EDIT

foreach (var item in someList)
    {
       var someName = item.SomeName;
       var result = (from t1 in someContext.Table1
                     join t2 in someContext.Table2 on 
                               new { t1.SomeID, SomeName = someName} 
                        equals new { t2.SomeID, t2.SomeName} into j1 
                                  ...
    }

Also check item.SomeName is same type as t2.SomeName

Problem

I have this query wit a group join: ``` foreach (var item in someList) { var result = (from t1 in someContext.Table1 join t2 in someContext.Table2 on new { t1.SomeID, item.SomeName} equals new {t2.SomeID, t2.SomeName} into j1 ... } ``` I would like to know if it is possible to have a group join as above? ``` new { t1.SomeID, item.SomeName} equals new {t2.SomeID, t2.SomeName} ``` `item.SomeName` comes from the list i am iterating through. If not, how would i change the statement to get the desired results?

Original source

Related problems