I have 6 columns in the Data table and the first column always unique so I have other data table there we have invalid Id so as per my requirement bot should compare with other datable and then it should skip the invalid id’s data then load other records
example:
225 rows in main data table
4 rows in invalid data table
so we need skip 4 rows then load 221 records
I have the linq queries but i am not getting desired the results
the main problem with linq query if any empty cell then it is throwing error “no source data found”
If dtData1.AsEnumerable.Intersect(dtData2.AsEnumerable, DataRowComparer.Default).Count > 0
Then Assign dt1Common=dtData1.AsEnumerable.Intersect(dtData2.AsEnumerable, DataRowComparer.Default).CopyToDataTable
Else Assign dt1Common-dtData1.Clone
If dtData1.AsEnumerable.Except(dt1Common.AsEnumerable, DataRowComparer.Default).Count > 0
Then Assign dt1NonCommon= dtData1.AsEnumerable.Except(dt1Common.AsEnumerable, DataRowComparer.Default).CopyToDataTable
Else Assign dt1NonCommon = dtData1.Clone
Basically check if the expression returns rows, if it does then do the comparison. If it does not, just clone the source DT so you get a DT with no rows as the result.
Its working but i am not getting correct results
I have 225 records are there
matching records 4 are there so as per my requirement i need to get only 221 records in dt1NonCommon but here i got the 225 records in the dt1NonCommon table