How to compare two datasets for equality
I have two datasets, each with one data table, retrieved from different sources, and I need to know if there are differences in the data contained in the data tables. I try to avoid looping and comparing every single record or column, although there is no other way. All I need to know is if the difference is in the data, I don't need to know the details of any difference.
I tried the below code but it seems that dataset.Merge is not updating rowstatus, so dataset.HasChanges () always returns false. Any help is appreciated:
var currentDataSet = GetSomeData();
var historicalDataSet = GetSomeHistoricalData();
historicalDataSet.Merge(currentDataSet);
if (historicalDataSet.HasChanges()) DoSomeStuff();
a source to share
I don't know of any built-in support for this, and I wouldn't expect that either. So you have to do it yourself.
The most obvious way might be brute force, table at table and row by step.
If you can rely on certain factors to be the same, i.e. exactly the same naming, ordering of records, etc., then you could check if both XML are stored and comparing the results can be an efficient trick.
a source to share