Delete Method
The Delete method marks the current observable data row as deleted.
This is a row-level operation that marks the row state as Deleted not removing the row from a table.
If the current state of the row is Added then Delete method throws an
exception because deletion means the added row must be removed from the table
it belongs to, but that action can be done at table level only.
/// <summary>
/// Deletes observable data row
/// </summary>
/// <param name="observableDataRow">Observable data row</param>
public static void Delete(this IObservableDataRow? observableDataRow)
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
Row in "Unchanged" state:
// 1. Create a new observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create observable table and row
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32, false, true);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Sales";
// 3. Accept the row changes
departmentObservableDataRow.AcceptChanges();
// 4. Call Delete method to put row into Deleted state
departmentObservableDataRow.Delete();
Row in "Added" state:
// 1. Create a new observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create observable table and row
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32, false, true);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Sales";
// 4. Call Delete method and observe thrown exception
departmentObservableDataRow.Delete();
Row in "Modified" state:
// 1. Create a new observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create observable table and row
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32, false, true);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Sales";
// 3. Accept the row changes
departmentObservableDataRow.AcceptChanges();
// 4. Update row to put it into Modified state
departmentObservableDataRow["Name"] = "Reception";
// 5. Call Delete method to put row into Deleted state
departmentObservableDataRow.Delete();
Table of Content POCO DataSet Observable Data Row Members
Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the
Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate
credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness
or suitability of the information and are not responsible for any damages
resulting from its use.