关于Linq to sql 怎么实现多表查询?

yoyo_ 2010-11-18 12:21:26
本人初学,这个多表查询让我纠结了,各位高手帮帮忙吧,谢谢啦!
如下:
这是SQL
select a.s910_01,a.s910_02,a.jobid,f.shift_B,f.shift_E,
case when s1.sums1 is null then 0 else s1.sums1 end as sums1
from BranchSchedule b inner join ats910 a on b.s910_01=a.s910_01
inner join contactdept c on a.deptid=c.id
inner join BranchShift f on b.s_shift=f.shift
left join (select empid,count(*) as sums1 from PTreservation
where
pos='502' and starttime between '201010' and '201011'
group by empid
) s1 on a.s910_01=s1.empid
where c.deptname like '%運動部'
and a.s910_36 is NULL and b.s_shift<>'@' and b.s210_01='502'
AND f.s210_01 = '502' and b.s_validity='201011' and
f.validity=(select max(f.validity) from BranchShift f
where f.shift=b.s_shift and f.s210_01='502') and b.s_day='18'
union (select a.s910_01,a.s910_02,a.jobid,s.on_time,s.off_time,
case when s1.sums1 is null then 0 else s1.sums1 end as sums1
from PTempshift s inner join ats910 a on a.s910_01 = s.empid
left join (select empid,count(*) as sums1 from PTreservation
where
pos='502' and starttime between '201010' and '201011'
group by empid
) s1 on a.s910_01=s1.empid
where s.pos = '502'
and s.shift_date =null)
order by a.jobid

现在要用LinQ来实现的话改怎么弄呢?
...全文
369 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shichao102471077 2010-11-18
  • 打赏
  • 举报
回复
额 。这个改成linq 杯具了。
q107770540 2010-11-18
  • 打赏
  • 举报
回复
你的SQL语句也太长了点吧...
claymore1114 2010-11-18
  • 打赏
  • 举报
回复
至少 有5、6张表吧,看得都累了,太长了。
yoyo_ 2010-11-18
  • 打赏
  • 举报
回复
哎,悲剧。。。
yzf86211861 2010-11-18
  • 打赏
  • 举报
回复
建 2到3个 试图吧 再用这2到3个 试图 写 linq。
纯的linq to SQL 写这种统计 很不方便
机器人 2010-11-18
  • 打赏
  • 举报
回复
写出来的Linq比SQL更多。。。

不要削足适履了。。。

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧