简体   繁体   中英

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();

I want to convert this C# LINQ query to SQL query.

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

I couldn't convert after this part. Is there anyone who can help me?

Here:

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

This could be your desired SQL Query

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM