How to join table with lamda expression in linq

Posted by Jitendrasoft09 under C# on 6/26/2013 | Points: 10 | Views : 2887 | Status : [Member] [MVP] | Replies : 1
Hi All,
I want to understand How to join table with lamda expression in linq, let me know if anybody knows.

Jitendra Kumar
If my post helps you, plz mark as an answer.


Posted by: Satyapriyanayak on: 6/27/2013 [Member] [MVP] Silver | Points: 25

Consider 3 tables tblEmployee, tblSalary, tblDepartment.

Here goes the query for grabbing employee name, salary and department name by joining above said three table using lambda.

Initially I am joining tblEmployee and tblSalary. Here sal is the object of table tblSalary and emp is the object of table tblEmployee. Then we are joining the last table tblDepartment. Finally we are filtering the record by Where condition.

IQueryable<Employee> val = DBContext.tblEmployee.Join(DBContext.tblSalary, emp =>, sal => sal.Employee_ID, (emp, sal) => new
.Join(DBContext.tblDepartment, emp =>, depart => depart.Employee_id, (emp, depart) => new Employee
Name = emp.Name,

Salary = emp.Basic_amount + emp.TDA_Allowance + emp.House_Rent,

Department = depart.Depart_Name

.Where(a => a.Name.Contains("Josh") && a.Salary >= 10000.00 );

To convert IQueryable to list :

List MyList = new List();

MyList = val.ToList();

public class Employee


public string Name{ get; set; };

public double Salary{ get; set; };

public string Department{ get; set; };


If this post helps you mark it as answer

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response