Reputation: 2086
I am having some trouble with a left join on two DataTables that uses multiple conditions. I am getting an error The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'
The error shows up on the keyword join
just before t2
var JoinedData= ((from t1 in TableOne.AsEnumerable()
join t2 in TableTwo.AsEnumerable() on
new { t1s = (string)t1["start_time"], t1r = (string)t1["reference_id"] }
equals
new { t2s = (string)t2["start_time"], t2r = (string)t2["reference_id"] }
select new {
id= (string)t1["reference_id"]
}
)).Distinct()
Everything works fine with one or the other, but when I combine them it gets the error.
Upvotes: 0
Views: 81
Reputation: 2183
Try replacing with anonymous objects with same properties names:
new { start_time = (string)t1["start_time"], end_time = (string)t1["reference_id"] }
equals
new { start_time = (string)t2["start_time"], end_time = (string)t2["reference_id"] }
Upvotes: 1