In this guide you will see how to use linq for a join operation on your data in Entity Framework
The JOIN statement is usually used to associate elements from different sources, when they share some value that can be compared for equality.
And when you don’t have navigation properties.
Let’s see how to do this, using Linq.
We created a really simple database created in the Entity Framework Database First Approach tutorial, and we will use it.
Using Linq, we don’t have to write any SQL code:
d => d.RobotFactoryId,
f => f.RobotFactoryId,
(d, f) => d)
As you can see, we used the Join method with the dot notation.
context.RobotDogs This is the starting point, the “from” statement
.Join(context.RobotFactories, The table to join with
d => d.RobotFactoryId, The primary key
f => f.RobotFactoryId, The foreign key
(d, f) => d) What to select from the join