[Mono-bugs] [Bug 67631][Wis] New - DataTable.Clone() needs to return a subclassed datatable when called from subclass
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 5 Oct 2004 15:56:38 -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 rscaletta@augustmack.com.
http://bugzilla.ximian.com/show_bug.cgi?id=67631
--- shadow/67631 2004-10-05 15:56:38.000000000 -0400
+++ shadow/67631.tmp.24539 2004-10-05 15:56:38.000000000 -0400
@@ -0,0 +1,58 @@
+Bug#: 67631
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: rscaletta@augustmack.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: DataTable.Clone() needs to return a subclassed datatable when called from subclass
+
+Description of Problem:
+See bug #67627 for more details... When you call DataTable.Clone() in a
+subclassed DataTable, it should return a DataTable of the same subclass.
+Instead, it returns a generic DataTable.
+
+Tested on mono 1.0. Doesn't appear to be fixed in CVS.
+
+Actual Results:
+Typed DataTable.
+
+Expected Results:
+Generic DataTable
+
+How often does this happen?
+Always.
+
+Additional Information:
+New clone method that works:
+------------
+public virtual DataTable Clone ()
+{
+ // Use Activator so we can use non-public constructors.
+ DataTable Copy = (DataTable) Activator.CreateInstance(GetType(), true);
+
+ CopyProperties (Copy);
+ return Copy;
+}
+------------
+also change this inside CopyProperties():
+
+. . .
+ // Copy columns
+ foreach (DataColumn Column in Columns) {
+ // When cloning a table, the columns may be added in the default
+ // constructor.
++ if (!Copy.Columns.Contains(Column.ColumnName)) {
+ Copy.Columns.Add (CopyColumn (
++ }
+ }
+. . .