There is a table I want to join with different columns in different tables.
This is how so far I did this
var purchData = (from a in db.AppRequest
join e in db.Employee on a.Req_By equals e.Id
join c in db.Company on e.CompanyId equals c.Id
join d in db.Designation on e.DesignId equals d.Id
join l in db.Master_Locations on a.Req_Location equals l.Id
join dep in db.Department on e.DepId equals dep.Id
join p in db.Purchase on a.Id equals p.Req_Id
join pi in db.PurchasingItems on p.Id equals pi.Purchase_Id
join pd in db.PurchasingDetails on p.Id equals pd.Purchase_Id
join pds in db.PurchasingDetailsSup on pd.Id equals pds.PurchasingDetails_Id
join s in db.M_Supplier on pds.Supp_Id equals s.Id
join payMethod in db.Master_PayMethods on s.Pay_Method equals payMethod.Id
join poNo in db.ApprovedPoNumbers on p.Id equals poNo.Purchase_Id
where a.Id == id && pds.IsApproved == true
In db.ApprovedPoNumbers table has purchase_Id and Supplier_Id
In db.PurchasingDetailsSup table has purchase_Id and Supplier_Id
So I want to know that here join poNo in db.ApprovedPoNumbers on p.Id equals poNo.Purchase_Id line I want to join the db.ApprovedPoNumbers table purchase_Id,Supplier_Id with db.PurchasingDetailsSup table purchase_Id and Supplier_Id
join on new {p.Id, p.Supplier_ID} equals new {poNo.Purchase_ID, poNo.Supplier_ID}However if you have FK relationships setup between these tables then you should also have Navigation properties and it would be better to use them instead of all the joins. coding.abel.nu/2012/06/dont-use-linqs-join-navigatejoin poNo in db.ApprovedPoNumbers on new { p.Id , pds.Supp_Id, } equals new {poNo.Purchase_Id, poNo.Supplier}Supplier Id is from another table related to PurchaseIDon new { Id = 3, x.Foo} equals new {y.Id, y.Foo}. What you cannot do is a more complex condition (anything that isn't of the forma = b AND c = d. For those you'd have to move some or all of the condition to the where clause instead.