User
User

Reputation: 1662

Compare Data tables

I need to compare the two data table, enter image description here

In both datatable we have the systemuserid . In datatable1 we have two rows.The system user id will start with c2dd... and 53cf...

Now i need to compare the two tables whther all systemuserids are available in second Datatable.

In these table the c2dd... sustem user is not available in the datatable 2. so i need to add that c2dd.. row in datatable 2 with noofCall as 0

Upvotes: 1

Views: 53

Answers (1)

Akash KC
Akash KC

Reputation: 16310

If you have two datatable available, then you can compare two table and get table1 row systemuserid which are not available in table2 in following way :

IEnumerable<DataRow> differenceRows = table1.AsEnumerable()
                                    .Where(x => table2.AsEnumerable()
                                    .All(y => y.Field<string>("systemuserid") != x.Field<string>("systemuserid")));

After getting differenceRows, you can add new row in table2 iterating through differenceRows.

Upvotes: 2

Related Questions