In LINQ, Join operators are used for integrating two data source into one data source which shares some common attributes. For example, in a bank, the manager has two lists, the first list contains the personal details and another list contains the home loan details. Now the manager wants to create a list which contains the names of those peoples who take a home loan and belong to the same place, so he uses join clause to create such type of list.
The join clause always takes two data source, the elements present the data source must contain some property so that it can compare with other data source. The result of the join clause depends upon which type of join clause is used. The most common types of the join are:
- Inner Join
- Cross Join
- Left outer join
- Group join
Inner Join
In LINQ, an inner join is used to serve a result which contains only those elements from the first data source that appears only one time in the second data source. And if an element of the first data source does not have matching elements, then it will not appear in the result data set. Here Join and Inner join are the same.
👁 Image
Important Points:
Example 1:
Output:
Employee and their Salary:
Employee Name: Anu Salary: 23000
Employee Name: Mohit Salary: 40000
Employee Name: Sona Salary: 50000
Employee Name: Lana Salary: 60000
Example 2: