+2003-11-09 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * DataRow.cs: Use RemoveInternal instead of Remove because the last
+ one uses Delete and AcceptChanges.
+
+ * DataRowCollection.cs: When removing, Delete and AcceptChanges
+ method from the row are called. Added an internal method that will
+ be used by DataRow to "physically" remove the row from the list.
+
2003-11-09 Pedro Martínez Juliá <yoros@wanadoo.es>
* DataRowCollection.cs: To follow the specification: Remove and
rowState = DataRowState.Unchanged;
break;
case DataRowState.Deleted:
- _table.Rows.Remove (this);
+ _table.Rows.RemoveInternal (this);
break;
case DataRowState.Detached:
throw new RowNotInTableException("Cannot perform this operation on a row not in the table.");
[MonoTODO]
public void Delete ()
{
+ _table.DeletingDataRow(this, DataRowAction.Delete);
switch (rowState) {
case DataRowState.Added:
- Table.Rows.Remove (this);
+ Table.Rows.RemoveInternal (this);
break;
case DataRowState.Deleted:
throw new DeletedRowInaccessibleException ();
default:
- _table.DeletingDataRow(this, DataRowAction.Delete);
// check what to do with child rows
CheckChildRows(DataRowAction.Delete);
rowState = DataRowState.Deleted;
- _table.DeletedDataRow(this, DataRowAction.Delete);
break;
}
+ _table.DeletedDataRow(this, DataRowAction.Delete);
}
// check the child rows of this row before deleting the row.
switch (rowState)
{
case DataRowState.Added:
- _table.Rows.Remove (this);
+ _table.Rows.RemoveInternal (this);
break;
case DataRowState.Modified:
rowState = DataRowState.Unchanged;
// if so: FIXME ;)
if ((rowState & DataRowState.Added) > 0)
- _table.Rows.Remove (this);
+ _table.Rows.RemoveInternal (this);
}
}
list.Insert (pos, row);
}
+ /// <summary>
+ /// Removes the specified DataRow from the internal list. Used by DataRow to commit the removing.
+ /// </summary>
+ internal void RemoveInternal (DataRow row) {
+ if (row == null) {
+ throw new IndexOutOfRangeException ("The given datarow is not in the current DataRowCollection.");
+ }
+ int index = list.IndexOf(row);
+ if (index < 0) {
+ throw new IndexOutOfRangeException ("The given datarow is not in the current DataRowCollection.");
+ }
+ list.RemoveAt(index);
+ }
+
/// <summary>
/// Removes the specified DataRow from the collection.
/// </summary>
int index = list.IndexOf(row);
if (index < 0)
throw new IndexOutOfRangeException ("The given datarow is not in the current DataRowCollection.");
- table.DeletingDataRow(row, DataRowAction.Delete);
- list.RemoveAt(index);
- table.DeletedDataRow(row, DataRowAction.Delete);
+ row.Delete();
+ row.AcceptChanges();
}
/// <summary>
if (index < 0 || index >= list.Count)
throw new IndexOutOfRangeException ("There is no row at position " + index + ".");
DataRow row = (DataRow)list [index];
- table.DeletingDataRow(row, DataRowAction.Delete);
- list.RemoveAt(index);
- table.DeletedDataRow(row, DataRowAction.Delete);
+ row.Delete();
+ row.AcceptChanges();
}
///<summary>