LINQ怎么写多表分组统计 200

selectKeyDBas服务器名,(selectcount(KeyDB)fromCompanyTotalwhereCompanyTotal.KeyDB=t.KeyDBa... select
KeyDB as 服务器名,
(select count(KeyDB) from CompanyTotal where CompanyTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' and (CompanyType != 'CarSynthesizeMonitor'and CompanyType != 'Service')) as '运输',
(select count(KeyDB) from CompanyTotal where CompanyTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' and (CompanyType = 'CarSynthesizeMonitor' or CompanyType = 'Service')) as '维修',
(select count(KeyDB) from UserTotal where UserTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' ) as '车辆',
(select count(KeyDB) from VehicleTotal where VehicleTotal.KeyDB=t.KeyDB and CreateTime <= '2016-7-7' ) as '人员'
from
(
select KeyDB from CompanyTotal group by KeyDB
union
select KeyDB from CompanyTotal group by KeyDB
union
select KeyDB from UserTotal group by KeyDB
union
select KeyDB from VehicleTotal group by KeyDB
) as t

该怎么改成LINQ???
展开
 我来答
liyan922107
2016-07-07 · 超过72用户采纳过TA的回答
知道小有建树答主
回答量:301
采纳率:0%
帮助的人:170万
展开全部
这么复杂最好还是不要改成linq了 因为用linq写起来更复杂 你直接做成视图或者存储过程 更方便 一样能用linqToSQL调用
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式