无法将SQL查询转换为Linq

时间:2012-11-07 09:04:56

标签: sql linq linq-to-sql

请帮我尝试转换此连接查询。我试图将以下SQL查询转换为LINQ查询,但无法使其工作。任何人都可以帮我解决这个问题吗?

SELECT T1.BoCode, case when T2.qty is null then 0 else T2.qty end 
FROM  
    (SELECT bocode from TABLE1) as T1
left join
    (SELECT cBoCode, sum(qty) as qty    FROM TABLE2 where ncampnurn in 
        (select nurn FROM TABLE3 INNER JOIN TABLE4 ON TABLE3.CampaignCode = 
         TABLE4.CampaignCode  
         where TABLE3.Month = 'Sep12' and TABLE4.ReportGroup = 'testgroup' )
    GROUP BY cBoCode) as T2 
ON T1.BoCode = T2.cBoCode
order by T1.BoCode

我只能做中间位,然后不知道我是否需要使用ContainsAny

from t3 in table3
join t4 in table4 on t3.CampaignCode equals t4.CampaignCode
where t3.Month == "Sep12" && t4.ReportGroup == "testgroup"
select t3.Nurn 

1 个答案:

答案 0 :(得分:0)

参考此

SQL to LINQ Tool

或自己动手

http://www.linqpad.net/