I've got a query that looks something like this, which works as it should:
ColumnA
.Join(ColumnB,
ColumnA => ColumnA.value,
ColumnB => ColumnB.value,
(ColumnA, ColumnB) => new {ColumnA, ColumnB})
.Join(ColumnC,
join1 => join1.ColumnA.value,
ColumnC => ColumnC.value,
(join1, ColumnC) => new {join1, ColumnC})
.Join(ColumnD,
join2 => join2.ColumnC.Value,
kobling => ColumnD.Value,
(join2, jk1Kobling) => new{ ... })
Now I need to add an extra column to the second join, and I tried what is shown below. As of yet, I haven't actually added a new column to the join, but I was planning to (/* new col */
in the code). The problem is that Linq is apparently not able to infer the types now. Why is this happening, and is there any simple way to avoid this problem, short of creating a specific type just for the sake of the join?
Error:
The type arguments for method
'System.Linq.Queryable.Join<TOuter,TInner,TKey,TResult>( ...) cannot
be inferred from the usage. Try specifying the type arguments explicitly.
The code I'm trying to run:
ColumnA
.Join(ColumnB,
ColumnA => ColumnA.value,
ColumnB => ColumnB.value,
(ColumnA, ColumnB) => new {ColumnA, ColumnB})
.Join(ColumnC,
join1 => new {join1.ColumnA.value, /* new col */ },
ColumnC => new {ColumnC.value, /* new col*/ },
(join1, ColumnC) => new {join1, ColumnC})
.Join(ColumnD,
join2 => join2.ColumnC.Value,
kobling => ColumnD.Value,
(join2, jk1Kobling) => new{ ... })
Update in response to the link in the comment below: The problem is related to the two middle lines here:
.Join(ColumnC,
join1 => new { join1.ColumnA.value },
ColumnC => new { ColumnC.value },
(join1, ColumnC) => new {join1, ColumnC})
I've now tried the following two things, without any changes to the result:
join1 => new { join1.ColumnA.value },
ColumnC => new { value = ColumnC.value }
join1 => new { value = join1.ColumnA.value },
ColumnC => new { value = ColumnC.value }
I'm still can't figure out how to specify what to compare. Any help would be greatly appreciated.