RejectChanges Method
The RejectChanges method rejects changes across the entire data set.
Internally, it iterates through all tables in the data set and calls RejectChanges() on each table.
Rejecting changes reverts the in-memory state back to the baseline values that were established by the last
successful AcceptChanges call. It is typically used when the user cancels an edit operation and the
application wants to discard all pending local changes.
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
public static void RejectChanges(this IDataSet? dataSet)
dataSet - data set. If null, the method does nothing.dataSet is null, returns immediately.dataSet.Tables and calls RejectChanges() on each table.
RejectChanges() is responsible for the row-level rules
(for example, removing Added rows, undeleting Deleted rows, restoring original values for Modified rows).
RejectChanges is not a validation step. Validation should happen at application layers.
RejectChanges is a local operation; it does not communicate with a database.
// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create Department observable table with one row in Added state
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Reception";
// 3. Create EmploymentType observable data table with one row in Modified state
IObservableDataTable employmentTypeObservableDataTable = observableDataSet.AddNewTable("EmploymentType");
employmentTypeObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
employmentTypeObservableDataTable.AddColumn("Code", DataTypeNames.STRING);
employmentTypeObservableDataTable.AddColumn("Description", DataTypeNames.STRING);
IObservableDataRow employmentTypeObservableDataRow = employmentTypeObservableDataTable.AddNewRow();
employmentTypeObservableDataRow["Id"] = 1;
employmentTypeObservableDataRow["Code"] = "ET01";
employmentTypeObservableDataRow["Description"] = "Full Time";
employmentTypeObservableDataRow.AcceptChanges();
employmentTypeObservableDataRow["Description"] = "Part Time";
// 4. Create Employee observable data table with one row in Deleted state
IObservableDataTable employeeObservableDataTable = observableDataSet.AddNewTable("Employee");
employeeObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
employeeObservableDataTable.AddColumn("FirstName", DataTypeNames.STRING);
employeeObservableDataTable.AddColumn("LastName", DataTypeNames.STRING);
IObservableDataRow employeeObservableDataRow = employeeObservableDataTable.AddNewRow();
employeeObservableDataRow["Id"] = 1;
employeeObservableDataRow["FirstName"] = "John";
employeeObservableDataRow["LastName"] = "Doe";
employeeObservableDataTable.AcceptChanges();
employeeObservableDataRow.Delete();
// 5. Reject changes at data set level
observableDataSet.RejectChanges();
// Expected result:
// - Department table without rows (Added row removed)
// - EmploymentType row restored to Unchanged: 1, ET01, Full Time
// - Employee row restored to Unchanged: 1, John, Doe
Table of Content POCO DataSet Observable Data Set 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.