I am trying to join two tables on three columns and I am getting an error:
error CS1941: The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.
I am not sure what’s going on. I checked the types of st_year, st_month, st_day year, month, and day and they are all int, so I shouldn’t be getting the error.
The code is:
var q = from obj in objTimeLine
join ev in eventsTimeLine
on new {obj.st_year, obj.st_month, obj.st_day} equals new {ev.year, ev.month, ev.day}
select new {obj, ev};
If I do however :
var q = from obj in objTimeLine
join ev in eventsTimeLine
on obj.st_year equals ev.year
select new {obj, ev};
Then there is no error and everything is fine, but I don’t know how to join than 2 other columns.
You need to make sure the anonymous type have the same property names like so: