使用多個條件,Join二個Table
Linq:
var Result= (from header in abc
join body in bcd on
new
{
one= header.
條件一 ,
two= header.條件二
} equals new { body.條件一, body.
條件二} into newResult
from body in newResult.DefaultIfEmpty()
select new abcType
{
a= body != null ? int.Parse(body.SOItemId) : 0,
b=header.CPSPN
}).ToList();
Inner Join、Outer Join、Right Join 、Left Join 示例
http://www.clarkrabbit.net/2009/01/code-snippet-left-join-inner-join-and.html
前提:兩個Join Table需是指定某類別之 List()
參考資料:
http://blog.darkthread.net/post-2010-08-12-linq-left-join.aspx