AcceptChanges Method
The AcceptChanges method accepts changes across the entire data set.
Internally, it iterates through all 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).
/// <summary>
/// Accepts changes
/// </summary>
/// <param name="dataSet">Data set</param>
public static void AcceptChanges(this IDataSet? dataSet)
Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll
dataSet is null, returns immediately.
dataSet.Tables and calls AcceptChanges() on each table.
AcceptChanges() typically:
Deleted state from the table.Added and Modified rows as Unchanged.Unchanged (and other non-changing) rows as-is.AcceptChanges is not a validation step. Validation should happen at application layers.
AcceptChanges is a local operation; it does not communicate with a database.
// 1. Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();
// 2. Table with one row in Added state
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);
IDataRow departmentDataRow = departmentDataTable.AddNewRow();
departmentDataRow["Id"] = 1;
departmentDataRow["Name"] = "Reception";
// 3. Table with one row in Modified state
IDataTable employmentTypeDataTable = dataSet.AddNewTable("EmploymentType");
employmentTypeDataTable.AddColumn("Id", DataTypeNames.INT32);
employmentTypeDataTable.AddColumn("Code", DataTypeNames.STRING);
employmentTypeDataTable.AddColumn("Description", DataTypeNames.STRING);
IDataRow employmentTypeDataRow = employmentTypeDataTable.AddNewRow();
employmentTypeDataRow["Id"] = 1;
employmentTypeDataRow["Code"] = "ET01";
employmentTypeDataRow["Description"] = "Full Time";
// Make the row Unchanged, then modify it
employmentTypeDataRow.AcceptChanges();
employmentTypeDataRow["Description"] = "Part Time";
// 4. Table with one row that will be deleted
IDataTable employeeDataTable = dataSet.AddNewTable("Employee");
employeeDataTable.AddColumn("Id", DataTypeNames.INT32);
employeeDataTable.AddColumn("FirstName", DataTypeNames.STRING);
employeeDataTable.AddColumn("LastName", DataTypeNames.STRING);
IDataRow employeeDataRow = employeeDataTable.AddNewRow();
employeeDataRow["Id"] = 1;
employeeDataRow["FirstName"] = "John";
employeeDataRow["LastName"] = "Doe";
employeeDataRow.AcceptChanges();
employeeDataRow.Delete();
// 5. Accept changes at data set level
dataSet.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 DataSet 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.