How to get match column names and unmatch column names from two data tables using linq

@marina.dutta

break down

For each row of dt1 select and load the data into dt3…
dt1.AsEnumerable.Select(function(x) dt3.Clone.LoadDataRow

First column to be quote number
({x(“Quote Number”).ToString,

From the matching row in dt2 with quote number in dt1…get the row as itemarray
String.Join(“,”,dt2.AsEnumerable.First(function(y) y(“Quote Number”).ToString.Equals(x(“Quote Number”).ToString)).ItemArray.

For each item in the array check if the value in dt2 and dt1 are matching then dont get column name else get the corresponding columnname and add it as second item or second column to dt3
Select(function(y,i) If(Not y.ToString.Equals(x(i).ToString),dt1.Columns(i).ColumnName,“”)).Cast(Of String).Where(function(z) Not STring.IsNullOrEmpty(z)))},False)).CopyToDataTable

hope this helps

cheers

2 Likes