How to make conversion SQL Inner joins query vs Entity Framework
14,070
Lambda syntax:
var query = db.Service_Orders
.Join(db.Project_Services,
a => a.so_no equals,
b => b.service_order,
(a,b) => new { a, b })
.Join(db.Company,
x => x.b.compid,
c => c.companyId,
(x,c) => new { x.a, x.b, c })
.Take(10);
Much more readable query syntax:
var query = (from a in db.Service_Orders
join b in db.Project_Services on a.so_no equals b.service_order
join c in db.Company on b.compid equals c.companyId
select new { a, b, c }).Take(10);
Author by
Abdul Khaliq
Updated on June 05, 2022Comments
-
Abdul Khaliq almost 2 years
Here are three tables Service_Orders, Project_Services and Company. There is inner join between 3 tables by Service Order and CompanyID. I want below query to convert into Entity framework with Lambda Express using C# or Vb.net.
select top 10 * from [Service_Orders] a,[Project_Services] b,[Company] c where a.so_no = b.service_order and c.companyId = b.compid