https://www.got-it.ai/solutions/sqlquerychat/sql-help/data-query/linq-to-sql-join-table-examples-c-querychat/

INNER JOIN 多条件匹配

  1. var query =
  2. from t1 in myTABLE1List // List<TABLE_1>
  3. join t2 in myTABLE1List
  4. on new { A = t1.ColumnA, B = t1.ColumnB } equals new { A = t2.ColumnA, B = t2.ColumnB }
  5. join t3 in myTABLE1List
  6. on new { A = t2.ColumnA, B = t2.ColumnB } equals new { A = t3.ColumnA, B = t3.ColumnB }
  7. ...

LEFT OUTER JOIN

  1. var query =
  2. from t1 in myTABLE1List // List<TABLE_1>
  3. join t2 in myTABLE1List
  4. on new { A = t1.ColumnA, B = t1.ColumnB } equals new { A = t2.ColumnA, B = t2.ColumnB }
  5. into temp from t3 in temp.DefaultIfEmpty()
  6. ...

RIGHT OUTER JOIN

  1. var query =
  2. join t2 in myTABLE1List
  3. from t1 in myTABLE1List // List<TABLE_1>
  4. on new { A = t2.ColumnA, B = t2.ColumnB } equals new { A = t1.ColumnA, B = t1.ColumnB }
  5. into temp from t3 in temp.DefaultIfEmpty()
  6. ...