[Mono-bugs] [Bug 79233][Nor] New - DuplicateNameException when two relations for different DataTables in DataSet are defined
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Aug 31 12:45:54 EDT 2006
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 gert.driesen at pandora.be.
http://bugzilla.ximian.com/show_bug.cgi?id=79233
--- shadow/79233 2006-08-31 12:45:54.000000000 -0400
+++ shadow/79233.tmp.2352 2006-08-31 12:45:54.000000000 -0400
@@ -0,0 +1,79 @@
+Bug#: 79233
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com
+ReportedBy: gert.driesen at pandora.be
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: DuplicateNameException when two relations for different DataTables in DataSet are defined
+
+When relations are defined for different DataTables in a DataSet, Mono
+determines the name for each individual DataRelationCollection, instead
+of calculating it on the DataSet level. This leads to a
+DuplicateNameException.
+
+To reproduce, compile and run the following code snippet:
+
+using System;
+using System.Data;
+
+public class Test
+{
+ static void Main ()
+ {
+ DataSet ds = new DataSet ();
+
+ DataTable dtChild = new DataTable ("Child");
+ dtChild.Columns.Add ("ParentId", typeof (int));
+ ds.Tables.Add (dtChild);
+
+ DataTable dtParent = new DataTable ("Parent");
+ dtParent.Columns.Add ("ParentId", typeof (int));
+ ds.Tables.Add (dtParent);
+
+ dtParent.ChildRelations.Add (dtParent.Columns [0],
+ dtChild.Columns [0]);
+ Console.WriteLine (dtParent.ChildRelations [0].RelationName);
+ dtChild.ChildRelations.Add (dtChild.Columns [0],
+ dtParent.Columns [0]);
+ Console.WriteLine (dtChild.ChildRelations [0].RelationName);
+ }
+}
+
+Expected result:
+
+Relation1
+Relation2
+
+Actual result:
+
+Relation1
+
+Unhandled Exception: System.Data.DuplicateNameException: A DataRelation
+named 'Relation1' already belongs to this DataSet.
+ at System.Data.DataRelationCollection.AddCore (System.Data.DataRelation
+relation) [0x00000]
+ at System.Data.DataRelationCollection+DataSetRelationCollection.AddCore
+(System.Data.DataRelation relation) [0x00000]
+ at System.Data.DataRelationCollection.Add (System.Data.DataRelation
+relation) [0x00000]
+ at
+System.Data.DataRelationCollection+DataTableRelationCollection.AddCore
+(System.Data.DataRelation relation) [0x00000]
+ at System.Data.DataRelationCollection.Add (System.Data.DataRelation
+relation) [0x00000]
+ at System.Data.DataRelationCollection.Add (System.Data.DataColumn
+parentColumn, System.Data.DataColumn childColumn) [0x00000]
+ at Test.Main () [0x00000]
+
+Note: I'll add a unit test for this bug to DataRelationTest2.cs. Please
+enable this test once the bug is fixed.
More information about the mono-bugs
mailing list