0

Performance wise what is the best way to compare 2 DataTables with approximate 1000 records?

I have looked into LINQ and DataRelation and googled a lot and was not able to reach a optimum solution for a datatable with only about 1000 records

Raidri
  • 17,258
  • 9
  • 62
  • 65
Arun Bertil
  • 4,598
  • 4
  • 33
  • 59

1 Answers1

2

Compare datatables in c# :

public static DataTable CompareTwoDataTable(DataTable dt1, DataTable dt2)
{ 
      dt1.Merge(dt2);
      DataTable d3 = dt2.GetChanges();    
      return d3;
}

I do prefer the above datatable inbuilt methods to achieve such a functionality as LINQ is doing an internal looping over the datatable rows for the process. As rows and columns goes up this may end up with perfomance leaks.

Praveen Prasannan
  • 7,093
  • 10
  • 50
  • 70