Linq Join on Mutiple columns using Anonymous type

I was working on the project using LINQ. I got the requirement to join the two entities in multiple columns.

For example, consider the following image. There are two entities, Distributor and Customer related to each other.

Now I want to find out all customers who live in same city where the distributor lives.

So to find that out, I have to make a join between Customer and Distributor. And to achieve this, I need to join by using multiple columns City, State, Country, ID. (Note: I am using id in join because later on I want to get which distributor is near which customer).

Now with the LINQ, you can join two entities on multiple columns by creating one anonymous type.

Note: As anonymous types are used to join entities on multiple columns, make sure that both are equal and they must have the same properties in the same order. Otherwise it doesn't get complied and you get an error.

Once you are done, run the code and you will see the following query in your SQL profiler or you can also use the Visual Studio feature to get the query.