countrymeister
asked on
Join on two datatables and List<T> in linq
How do I Join on two datatables and a list<string>
var result = from dataRows1 in DataTable1.AsEnumerable()
join dataRows2 in DataTable2.AsEnumerable()
on dataRows1["ID"] equals dataRows2["ID"]
join dataRows3 in dataList.AsEnumerable()
on dataRows2["Code"] equals dataRows3[0]
select joinedTable.NewRow().ItemA rray = new object[]{
dataRows1["ID"],
dataRows2["Code"],
dataRows2["Price"],
};
var result = from dataRows1 in DataTable1.AsEnumerable()
join dataRows2 in DataTable2.AsEnumerable()
on dataRows1["ID"] equals dataRows2["ID"]
join dataRows3 in dataList.AsEnumerable()
on dataRows2["Code"] equals dataRows3[0]
select joinedTable.NewRow().ItemA
dataRows1["ID"],
dataRows2["Code"],
dataRows2["Price"],
};
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
datRows3 is a List<string>
var result = from dataRows1 in Table1.AsEnumerable()
join dataRows2 in Table2.AsEnumerable()
on dataRows1["ID"] equals dataRows2["ID"]
join dataRows3 in dateList.AsEnumerable()
on dataRows2["Code"] equals dataRows3
select joinedTable.NewRow().ItemA
dataRows1["ID"],
dataRows2["Code"],
dataRows2["Price"],
};