Author: senga
Date: 2006-01-17 07:46:05 -0500 (Tue, 17 Jan 2006)
New Revision: 55679
Modified:
branches/mono-1-1-13/mcs/class/System.Data/System.Data/ChangeLog
branches/mono-1-1-13/mcs/class/System.Data/System.Data/DataRow.cs
branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/ChangeLog
branches/mono-1-1-13/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 RowNotInTableException only if
the concerned row has been removed from the table.Fixes
bug #77267
Modified: branches/mono-1-1-13/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/class/System.Data/System.Data/ChangeLog
2006-01-17 12:38:04 UTC (rev 55678)
+++ branches/mono-1-1-13/mcs/class/System.Data/System.Data/ChangeLog
2006-01-17 12:46:05 UTC (rev 55679)
@@ -1,3 +1,9 @@
+2006-01-17 Senganal T <[EMAIL PROTECTED]>
+ * DataRow.cs:
+ ItemArray : Modified to raise RowNotInTableException only if
+ the concerned row has been removed from the table.Fixes
+ bug #77267
+
2006-01-10 Senganal T <[EMAIL PROTECTED]>
* DataRowCollection.cs
- Added ListChangedEvent to signal reset of the collection.
Modified: branches/mono-1-1-13/mcs/class/System.Data/System.Data/DataRow.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/System.Data/System.Data/DataRow.cs
2006-01-17 12:38:04 UTC (rev 55678)
+++ branches/mono-1-1-13/mcs/class/System.Data/System.Data/DataRow.cs
2006-01-17 12:46:05 UTC (rev 55679)
@@ -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: branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/ChangeLog
2006-01-17 12:38:04 UTC (rev 55678)
+++ branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/ChangeLog
2006-01-17 12:46:05 UTC (rev 55679)
@@ -1,3 +1,7 @@
+2006-01-17 Senganal T <[EMAIL PROTECTED]>
+
+ * DataRowTest2.cs : added testcase for bug #77267
+
2006-01-10 Senganal T <[EMAIL PROTECTED]>
* DataViewTest2.cs
- Added testcase for bug #77188
Modified:
branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
2006-01-17 12:38:04 UTC (rev 55678)
+++ branches/mono-1-1-13/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
2006-01-17 12:46:05 UTC (rev 55679)
@@ -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