如何将SQL select语句转换为LINQ

时间:2013-09-26 07:04:05

标签: sql linq

您好我是SQL和LINQ的新手,我需要将此sql语句转换为LINQ

select r.*, 
(Select name From org_table where org_ID= r.org_ID )org
(Select name From Depart_table where Depart_ID= r.Depart_ID)depart
from reserve_table r 
where name like '

1 个答案:

答案 0 :(得分:0)

以这种方式尝试:

var result = from r in reserve_table
             where r.name.Contains("something")
             select new {
                          org = (from o in org_table where o.Org_ID = r.Org_ID select o.name)
                          depart = (from d in Depart_table where d.Depart_ID = r.Depart_ID select d.name)
                          // add the rest
                        }