none
Best Ways Of Comparing Datasets RRS feed

  • Question

  • Hi,

     

    I know of a couple of ways to compare the contents of two identically structured datasets - using a merge into a third and HasChanges or using GetXML and comparing strings.

     

    Are there any recommendations around using either of the above methods (e.g. one is worse than the other for performance etc)?

     

    Also, are there any other better ways than the two above?

     

    Cheers

    Dan

     

    Monday, June 9, 2008 8:58 AM

All replies


  • Hi, I would also like to know how to compare two datasets (typed) using Unit Test.

    Thanks !

    Monday, June 9, 2008 2:12 PM
  • PS I can see that my post has been moved from the Team System DB forum - I actually only posted there originally coz Michael Koltachev - MSFT advised me to! I don't mind my posts being moved to a more correct forum, but it would be nice to be told that it has happened and maybe even let me know where it has gone to ;-)
    Tuesday, June 10, 2008 7:19 AM
  • I do not have the "best way" but I have two ways to compare them. Smile

    1. Get the hash code and compare them. They would be probably the same if the hash codes are the same.

    2. Compare each columns and rows of each of the datatables in both datasets.

    Wednesday, June 11, 2008 5:54 AM
  • comparing each column and row would defintely do the trick, but i was hoping for a faster way!

     

    hash code sounds interesting - how do you get the hash code of a dataset?

     

    also, does anyone have any experience using any other methods? i can see that there are numerous different ways to do it, but i am sure each has its own pros and cons and it is this that i am really after (googling doesnt produce a lot and sometimes even gives conflicting arguments/suggestions!)

     

     

    Wednesday, June 11, 2008 8:00 AM
  • Comparing each single item between the datasets is the fastest way for general datasets.

     

    Could you please describe structure of the datasets? There may be some constraints that can be used to optimize the comparison.

    Wednesday, June 11, 2008 1:14 PM
  • I found that I've made a mistake. GetHashCode() of DataSet was not overridden so we could not use that. So there's only one way from me: foreach

    Thursday, June 12, 2008 5:50 AM