2004-06-15 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 15 Jun 2004 09:50:39 +0000 (09:50 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 15 Jun 2004 09:50:39 +0000 (09:50 -0000)
* DataSet.cs : children of non-root rows were not properly written.
  Fixed bug #53959.

svn path=/trunk/mcs/; revision=29591

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataSet.cs

index b0e6a3857699e8cef67c14386385e4a444353646..4a46dc831b0d1cd733e9ed93518c54bc339af285 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DataSet.cs : children of non-root rows were not properly written.
+         Fixed bug #53959.
+
 2004-06-10 Umadevi S <sumadevi@novell.com>
        * DataRelation.cs - Constructor
        - The datatypes of the parentcolumn(s) and the childcolumn(s) should match
index b1f8b698e6130bcaa36f7168401e015431eb524d..e5ef148e74695dab1432bce805997f4c63efa141 100644 (file)
@@ -1127,10 +1127,10 @@ namespace System.Data {
                {
                        DataRow[] rows = new DataRow [table.Rows.Count];
                        table.Rows.CopyTo (rows, 0);
-                       WriteTable (writer, rows, mode, version);
+                       WriteTable (writer, rows, mode, version, true);
                }
 
-               private void WriteTable (XmlWriter writer, DataRow[] rows, XmlWriteMode mode, DataRowVersion version)
+               private void WriteTable (XmlWriter writer, DataRow[] rows, XmlWriteMode mode, DataRowVersion version, bool skipIfNested)
                {
                        //The columns can be attributes, hidden, elements, or simple content
                        //There can be 0-1 simple content cols or 0-* elements
@@ -1147,24 +1147,26 @@ namespace System.Data {
                        DataRelation oneRel = relationCount == 1 ? table.ParentRelations [0] : null;
 
                        foreach (DataRow row in rows) {
-                               // Skip rows that is a child of any tables.
-                               switch (relationCount) {
-                               case 0:
-                                       break;
-                               case 1:
-                                       if (row.GetParentRow (oneRel) != null)
-                                               continue;
-                                       break;
-                               case 2:
-                                       bool skip = false;
-                                       for (int i = 0; i < table.ParentRelations.Count; i++)
-                                               if (row.GetParentRow (table.ParentRelations [i]) != null) {
-                                                       skip = true;
+                               if (skipIfNested) {
+                                       // Skip rows that is a child of any tables.
+                                       switch (relationCount) {
+                                       case 0:
+                                               break;
+                                       case 1:
+                                               if (row.GetParentRow (oneRel) != null)
                                                        continue;
-                                               }
-                                       if (skip)
-                                               continue;
-                                       break;
+                                               break;
+                                       case 2:
+                                               bool skip = false;
+                                               for (int i = 0; i < table.ParentRelations.Count; i++)
+                                                       if (row.GetParentRow (table.ParentRelations [i]) != null) {
+                                                               skip = true;
+                                                               continue;
+                                                       }
+                                               if (skip)
+                                                       continue;
+                                               break;
+                                       }
                                }
 
                                if (!row.HasVersion(version) || 
@@ -1205,7 +1207,7 @@ namespace System.Data {
                                
                                foreach (DataRelation relation in table.ChildRelations) {
                                        if (relation.Nested) {
-                                               WriteTable (writer, row.GetChildRows (relation), mode, version);
+                                               WriteTable (writer, row.GetChildRows (relation), mode, version, false);
                                        }
                                }
                                
@@ -1302,6 +1304,7 @@ namespace System.Data {
                        }
                        writer.WriteEndElement (); // DataSet name or diffgr:diffgram
                }
+               
 
                private void CheckNamespace (string prefix, string ns, XmlNamespaceManager nsmgr, XmlSchema schema)
                {