简体   繁体   中英

How to Compare two “DataSet” in C#

I have 2 DataSet's in my code, I want to compare the equality of the data in these 2 dataset's.

Code:

DataSet dsXmlData1 = new DataSet();                
dsXmlData1.ReadXml(new StringReader(queryElements));

DataSet dsXmlData2 = new DataSet();
dsXmlData2.ReadXml(reader);

Comparision:

if(dsXmlData1 == dsXmlData2){}

In this example dsXmlData1 & dsXmlData2 are Dataset's.

Thanks

You can compare them like this too:

foreach (DataTable TblDefault in ds.Tables) \\ gridview values
{
        foreach (DataTable Tbldefault1 in ds1.Tables) \\databasevalues
         {
             if (TblDefault.TableName.ToUpper().Trim() == Tbldefault1.TableName.ToUpper().Trim())
             {
                  //Here
             }
         }
}

似乎您在寻找XMLDiff

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM