AcceptChanges Method
The AcceptChanges method accepts changes for all rows in a table.
It is the table-level equivalent of committing the current in-memory state as the new baseline.
A key difference compared to row-level acceptance is how deletions are handled:
when a row is in Deleted state, accepting that deletion removes the row from the table.
For this reason, this method iterates rows from the end to the beginning and removes deleted rows
safely by index.
/// <summary>
/// Accepts changes for observable table (delegates to inner table)
/// </summary>
/// <param name="observableDataTable">Observable data table</param>
public static void AcceptChanges(this IObservableDataTable? dataTable)
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
dataTable is null, returns immediately.Rows.Count - 1 down to 0.
This backward iteration is required because accepting a deletion removes the row from the table.
Deleted: the method commits the deletion by removing the row from the table
via RemoveRowAt(index).
Added and Modified: the method calls IDataRow.AcceptChanges(),
which typically transitions the row to Unchanged.
Unchanged and Detached: no action is taken.
AcceptChanges while there are unsaved deleted rows, those rows will be permanently removed
from the table (in-memory). The caller must understand and accept this consequence.
// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create Department observable table with rows in different states
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
// Row in Added state
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Reception";
// Row in Deleted state
departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 2;
departmentObservableDataRow["Name"] = "Emergency";
departmentObservableDataRow.AcceptChanges();
departmentObservableDataRow.Delete();
// Row in Modified state
departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 3;
departmentObservableDataRow["Name"] = "Emergency";
departmentObservableDataRow.AcceptChanges();
departmentObservableDataRow["Name"] = "Finance";
// 4. Accept changes at table level
// - row1 remains in the table and becomes Unchanged
// - row2 is removed from the table because it was Deleted
// - row3 remains in the table and becomes Unchanged
departmentObservableDataTable.AcceptChanges();
Table of Content POCO DataSet Observable Data Table 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.