原來linq對於List及DataTable在做join寫法是不同的,try了很久
log下來囉!
泛型的範例
var var1 = (from d10 in d0
join d11 in d1 on new { d10.companyno, d10.chkdebtno, d10.itemno }
equals new { d11.companyno, d11.chkdebtno, d11.itemno }
where d10.discounttype == "N"
select new
{
outqty = d11.outqty
,outprice = d11.outprice
,outbackqty =d11.outbackqty
,outbackprice = d11.outbackprice
}).ToList();
datatable的範例
DataTable inbal = (from x in dtBal.AsEnumerable()
join z in dtBat.AsEnumerable()
on new { companyno=x.Field<string>("companyno"),partno= x.Field<string>("partno") } equals
new {companyno=z.Field<string>("companyno") ,partno=z.Field<string>("partno") }
select x).CopyToDataTable() ;