将 LINQ 查询转换为 SQL

Convert LINQ query to SQL

var list = (from t1 in table1 ✓

join t2 in table2 on t1.xyz equals t2.abc ✓

join t3 in table3 on new { t1.abc , t2.qwe} equals new { t3.abc , t3.qwe}

select new Table
{

XYZ= t1.xyz,

ABC = t1.abc,

 QWE= t3.qwe

}).Distinct().ToList();

我想将此 C# LINQ 查询转换为 SQL 查询。

join t3 in table3 on new { t1.abc , t2.qwe} equals new { t3.abc , t3.qwe}

这部分后我无法转换。有没有人可以帮助我?

这里:

SELECT  DISTINCT t1.xyz AS XYZ, t1.abc AS ABC, t3.qwe AS QWE
FROM    table1 t1
JOIN    table2 t2 ON t1.xyz = t2.abc
JOIN    table3 t3 ON t1.abc = t3.abc AND t2.qwe = t3.qwe

这可能是您想要的SQL查询

SELECT  DISTINCT t1.xyz AS XYZ, t1.abc AS ABC, t3.qwe AS QWE
FROM    table1 t1
JOIN    table2 t2 ON t1.xyz = t2.abc
JOIN    table3 t3 ON t1.abc = t3.abc AND t2.qwe = t3.qwe