2016-06-09 149 views

回答

1

那么,对于内部联接,你的SQL会大大只

select a.Column1, a.Column2 
from Table1 a 
join Table2 b on b.Column1 = a.Column1 
where a.Column3 = 'Something2' and b.ColumnB = 'Something1' 

更具可读性现在,你可以做,在伪LINQ

from a in Table1 
join b in Table2 on a.Column1 equals b.Column1 
where b.ColumnB == "Something1" and a.Column3 = ="Something2" 
select new { 
    col1 = a.Column1, 
    col2 = a.Column2 
}; 

或也

from a in Table1.Where(t => t.Column3 == "Something2" 
join b in Table2.Where(t => t.ColumnB == "Something1") 
      on a.Column1 equals b.Column1 
select new { 
    col1 = a.Column1, 
    col2 = a.Column2 
}; 
+0

woow!有效。我使用了“.Where(t => t.Column3 ==”Something2“”版本。非常感谢 –