AcceptChanges Method

Overview

The AcceptChanges method accepts changes across the entire observable data set. Internally, it iterates through all observable tables and calls AcceptChanges() on each table. Table-level acceptance is important because accepting deleted rows removes them from the table.

AcceptChanges is commonly used after a successful save operation, or after you decide that the current in-memory state should be treated as the new baseline (no pending local changes).

Declaration

/// <summary>
/// Accepts changes for observable data set
/// </summary>
/// <param name="observableDataSet">Observable data set</param>
public static void AcceptChanges(this IObservableDataSet? observableDataSet)

Namespace and Assembly

Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll

Important Notes

Usage Example

// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();

// 2. 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. 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";

// Make the row Unchanged, then modify it
employmentTypeObservableDataRow.AcceptChanges();
employmentTypeObservableDataRow["Description"] = "Part Time";

// 4. 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";
employeeObservableDataRow.AcceptChanges();
employeeObservableDataRow.Delete();

// 5. Accept changes at data set level
observableDataSet.AcceptChanges();

// Expected result:
// - Department: one Unchanged row (1, Reception)
// - EmploymentType: one Unchanged row (1, ET01, Part Time)
// - Employee: deleted row removed from the table

 

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.