求帮忙将这条SQL语句转成LINQ语句。谢谢!
select C_ParentID ,C_CompanyIDfrom T_StaffComList
left join T_Company on T_StaffComList.SC_ManageComId = T_Company.C_CompanyID
where SC_StaffId=11353
union all
select C_ParentID ,T_Company.C_CompanyID
from T_Staff
left join T_Company on T_Staff.C_CompanyID = T_Company.C_CompanyID
where C_StaffID=11353
用LINQ语句表达就得了,
var q =
T_StaffComList 和T_Staff 这二张表都差不多的,只是要用union all 联合起来
如题,小弟感激! --------------------编程问答-------------------- 你要交待清楚 表结构
比如SC_StaffId C_StaffID 这都是哪张表的字段? --------------------编程问答--------------------
var query= (from ts in T_StaffComList.Where(x=>x.SC_StaffId == 11353)
join tc in T_Company on ts.SC_ManageComId equals tc.C_CompanyID into lg
from tc in lg.DefaultIfEmpty()
select new {ParentID =tc==null?0:tc.C_ParentID, CompanyID=tc==null?0:tc.C_CompanyID}).UnionAll
(from ts in T_Staff.Where(x=>x.C_StaffId == 11353)
join tc in T_Company on ts.C_CompanyID equals tc.C_CompanyID into lg
from tc in lg.DefaultIfEmpty()
select new {ParentID =tc==null?0:tc.C_ParentID, CompanyID=tc==null?0:tc.C_CompanyID});
补充:.NET技术 , LINQ