C# 将 SQL 转换为 LINQ 查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8988531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 05:28:11  来源:igfitidea点击:

Convert SQL to LINQ Query

c#sqllinq

提问by Francisco G

I have the following SQL query and I need to have it in LINQ, I tried several things but I can not get it working.

我有以下 SQL 查询,我需要在 LINQ 中使用它,我尝试了几件事,但无法使其正常工作。

Here is the SQL query

这是 SQL 查询

SELECT     ST.Description, ST.STId, COUNT(SI.SIId) AS Expr1
FROM         BP INNER JOIN
                      MbrBP ON BP.BPId = MbrBP.BPId INNER JOIN
                      SI ON BP.BPId = SI.BPId RIGHT OUTER JOIN
                      ST ON SI.STId = ST.STId
WHERE     (BP.CountryId = 1) AND (BP.RegionId = 1) AND (MbrBP.MemberId = 1)
      AND (SI.IsActive = 1)
GROUP BY ST.Description, ST.STId
UNION 
SELECT      ST.Description, ST.STId, COUNT(SI.STId) AS Expr1
FROM         SI RIGHT OUTER JOIN
                      ST ON SI.STId = ST.STId
GROUP BY ST.Description, ST.STId

采纳答案by beebul

Have you tried Linqer http://www.sqltolinq.com

你试过 Linqer http://www.sqltolinq.com

An SQL-> LINQ converter..

SQL-> LINQ 转换器..

Or LINQPad http://www.linqpad.net/

或者 LINQPad http://www.linqpad.net/