var result = from dataRows1 in table1.AsEnumerable()
join dataRows2 in table2.AsEnumerable()
on dataRows1.Field<string>("ID") equals dataRows2.Field<string>("ID") into lj
from r in lj.DefaultIfEmpty()
select dtResult.LoadDataRow(new object[]
{
dataRows1.Field<string>("ID"),
dataRows1.Field<string>("name"),
r == null ? 0 : r.Field<int>("stock")
}, false);
This blog contains Azure, .Net, SQL & Full stack development concepts and code fixes.
Monday, 4 July 2016
Join Two DataTables Using LINQ in C#
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment