Author: senga
Date: 2006-01-17 06:54:14 -0500 (Tue, 17 Jan 2006)
New Revision: 55675
Modified:
trunk/mcs/class/System.Data/System.Data/ChangeLog
trunk/mcs/class/System.Data/System.Data/DataRow.cs
trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
Log:
2006-01-17 Senganal T <[EMAIL PROTECTED]>
* Test/System.Data/DataRowTest2.cs : added testcase for bug #77267
* System.Data/DataRow.cs:
ItemArray : Modified to raise RowInTableException only if
the concerned row has been removed from the table.Fixes
bug #77267
Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog 2006-01-17 11:45:48 UTC
(rev 55674)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog 2006-01-17 11:54:14 UTC
(rev 55675)
@@ -1,3 +1,10 @@
+2006-01-17 Senganal T <[EMAIL PROTECTED]>
+
+ * DataRow.cs:
+ ItemArray : Modified to raise RowInTableException only if
+ the concerned row has been removed from the table.Fixes
+ bug #77267
+
2006-01-16 Boris Kirzner <[EMAIL PROTECTED]>
* DataTable.cs: Drop dependend indexes on column removal.
Modified: trunk/mcs/class/System.Data/System.Data/DataRow.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRow.cs 2006-01-17 11:45:48 UTC
(rev 55674)
+++ trunk/mcs/class/System.Data/System.Data/DataRow.cs 2006-01-17 11:54:14 UTC
(rev 55675)
@@ -180,7 +180,6 @@
}
CheckValue (value, column);
-
bool orginalEditing = Proposed >= 0;
if (!orginalEditing) {
BeginEdit ();
@@ -274,17 +273,26 @@
/// </summary>
public object[] ItemArray {
get {
- // row not in table
- if (RowState == DataRowState.Detached)
- throw new RowNotInTableException("This
row has been removed from a table and does not have any data. BeginEdit() will
allow creation of new data in this row.");
// Accessing deleted rows
if (RowState == DataRowState.Deleted)
throw new
DeletedRowInaccessibleException ("Deleted row information cannot be accessed
through the row.");
+
+ int index = 0;
+ if (RowState == DataRowState.Detached)
+ // Check if datarow is removed from the
table.
+ if (Proposed < 0)
+ throw new
RowNotInTableException(
+ "This row has
been removed from a table and does not have any data."
+ +" BeginEdit()
will allow creation of new data in this row.");
+ else
+ index = Proposed;
+ else
+ index = Current;
object[] items = new
object[_table.Columns.Count];
- foreach(DataColumn column in _table.Columns) {
- items[column.Ordinal] = column[Current];
- }
+
+ foreach(DataColumn column in _table.Columns)
+ items[column.Ordinal] = column[index];
return items;
}
set {
Modified: trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/ChangeLog 2006-01-17
11:45:48 UTC (rev 55674)
+++ trunk/mcs/class/System.Data/Test/System.Data/ChangeLog 2006-01-17
11:54:14 UTC (rev 55675)
@@ -1,3 +1,7 @@
+2006-01-17 Senganal T <[EMAIL PROTECTED]>
+
+ * DataRowTest2.cs : added testcase for bug #77267
+
2006-01-16 Boris Kirzner <[EMAIL PROTECTED]>
* DataColumnCollectionTest2.cs: added test case for index update on
column removal
Modified: trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
2006-01-17 11:45:48 UTC (rev 55674)
+++ trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
2006-01-17 11:54:14 UTC (rev 55675)
@@ -1486,6 +1486,24 @@
Assert.Fail("DRW136: Add. Wrong exception type.
Got:" + exc);
}
}
+
+ [Test]
+ public void ItemArray_NewTable ()
+ {
+ DataTable dt = new DataTable("Customers");
+
+ dt.Columns.Add("name", typeof (string));
+ dt.Columns.Add("address", typeof (string));
+ dt.Columns.Add("phone", typeof (string));
+
+ DataRow dr = dt.NewRow();
+ dr["name"] = "myName";
+ dr["address"] = "myAddress";
+ dr["phone"] = "myPhone";
+
+ // Should not throw RowNotInTableException
+ object[] obj = dr.ItemArray;
+ }
private DataTable GetDataTable()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches