How to create a simple JOIN LINQ query to fetch data from 2 entities?
The below LINQ query will retrieve the Employee details by joining (inner join) Department table to fetch the DepartmentName using the DeptID in Employee table. EmployeeInfoDataContext dbEmp = new EmployeeInfoDataContext(); var query = from emp in dbEmp.Employees join dept in dbEmp.Departments on emp.DeptID equals dept.DeptID select new { EmpID = emp.EmpID, EmpName = emp.EmpName, Age = emp.Age, Address = emp.Address, DeptName = dept.DepartmentName };
|
|