[Mono-bugs] [Bug 68007][Nor] New - DataSet.GetObjectData(), DataSet serialization, renders the null data within DataColumns w/ ColumnMapping = Attribute as empty attribute instead of not rendering the attribute
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 11 Oct 2004 19:38:54 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by dclough@prconline.com.
http://bugzilla.ximian.com/show_bug.cgi?id=68007
--- shadow/68007 2004-10-11 19:38:54.000000000 -0400
+++ shadow/68007.tmp.29716 2004-10-11 19:38:54.000000000 -0400
@@ -0,0 +1,88 @@
+Bug#: 68007
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: Fedora Core 2
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: dclough@prconline.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: DataSet.GetObjectData(), DataSet serialization, renders the null data within DataColumns w/ ColumnMapping = Attribute as empty attribute instead of not rendering the attribute
+
+Steps to reproduce the problem:
+
+Paste the following code into a simple Console App:
+
+DataSet ds = new DataSet("Example");
+
+// Add a DataTable
+ds.Tables.Add("Packages");
+
+// Add an ID DataColumn w/ ColumnMapping = MappingType.Attribute
+ds.Tables["Packages"].Columns.Add(new DataColumn("ID", typeof(int), "",
+MappingType.Attribute));
+ds.Tables["Packages"].Columns["ID"].AllowDBNull = false;
+
+// Add a nullable DataColumn w/ ColumnMapping = MappingType.Attribute
+ds.Tables["Packages"].Columns.Add(new DataColumn("ShipDate", typeof
+(DateTime), "", MappingType.Attribute));
+ds.Tables["Packages"].Columns["ShipDate"].AllowDBNull = true;
+
+// Add a nullable DataColumn w/ ColumnMapping = MappingType.Attribute
+ds.Tables["Packages"].Columns.Add(new DataColumn("Message", typeof
+(string), "", MappingType.Attribute));
+ds.Tables["Packages"].Columns["Message"].AllowDBNull = true;
+
+// Add a nullable DataColumn w/ ColumnMapping = MappingType.Attribute
+ds.Tables["Packages"].Columns.Add(new DataColumn("Handlers", typeof
+(int), "", MappingType.Attribute));
+ds.Tables["Packages"].Columns["Handlers"].AllowDBNull = true;
+
+// Add a non-null value row
+DataRow newRow = ds.Tables["Packages"].NewRow();
+newRow["ID"] = 0;
+newRow["ShipDate"] = DateTime.Now;
+newRow["Message"] = "Received with no breakage!";
+newRow["Handlers"] = 3;
+ds.Tables["Packages"].Rows.Add(newRow);
+
+// Add a null value row
+newRow = ds.Tables["Packages"].NewRow();
+newRow["ID"] = 1;
+newRow["ShipDate"] = DBNull.Value;
+newRow["Message"] = DBNull.Value;
+newRow["Handlers"] = DBNull.Value;
+ds.Tables["Packages"].Rows.Add(newRow);
+
+ds.AcceptChanges();
+
+// Serialize the DataSet to a file
+string fileName = @"FILENAME_HERE";
+
+XmlTextWriter writer = new XmlTextWriter(fileName,
+System.Text.Encoding.UTF8);
+XmlSerializer serializer = new XmlSerializer(ds.GetType());
+
+serializer.Serialize(writer, ds);
+writer.Close();
+
+Actual Results:
+
+See Attached File.
+
+
+Expected Results:
+
+See Attached File.
+
+
+How often does this happen?
+
+Repeatable with the provided code.