Let’s start by saying the code in this example is a really silly, but it’s a great reference for the matter at hand. Let’s assume you need to do a join on multiple columns and you’ve double checked and triple checked that the types are all the same, but you’re stuck with the following error:
The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to ‘Join’.
The problem is related to anonymous types. The type initializer cannot infer the same anonymous type because the names are not the same. The solution is simple: specify the name in one of the expressions such that they are the same and the problem is solved.
Now that the types AND the names are the same, the anonymous type initializer can create the same anonymous type and properly facilitate the join.
I hope this helps someone.
Elegant Software Solutions, LLC