OriginalValues Property
The OriginalValues property provides read-only access to the
baseline values of a data row, captured at the moment the row first
transitions away from the Unchanged state.
A snapshot of original values is created automatically by the framework
when an Unchanged row is modified for the first time, or when the
Delete method is called. The snapshot represents the row’s
original state prior to modification or deletion.
The snapshot is used by the RejectChanges method to restore
the row’s values to their original baseline. When AcceptChanges
is called for Added or Modified rows, the snapshot is discarded
and the current values become the new baseline.
If a row does not currently hold a snapshot, the
OriginalValues property returns an empty read-only dictionary.
Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
// 1. Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();
// 2. Create an empty data table
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);
// 3. Create a new row by AddNewRow method on data table, the row state is Added
IDataRow departmentDataRow = departmentDataTable.AddNewRow();
departmentDataRow["Name"] = "Emergency";
// 4. Verify that the snapshot of original values is empty
IReadOnlyDictionary<string, object?> dataRowOriginalValues = departmentDataRow.OriginalValues;
int dataRowOriginalValuesCount = dataRowOriginalValues.Count;
// 5. Call AcceptChanges method to set row state into Unchanged
departmentDataRow.AcceptChanges();
// 6. Verify that the snapshot of original values is empty
dataRowOriginalValues = departmentDataRow.OriginalValues;
dataRowOriginalValuesCount = dataRowOriginalValues.Count;
// 7. Modify row data to put it into Modified state
departmentDataRow["Name"] = "Reception";
// 8. Verify that the snapshot of original values contains data
// because the modification of any value of row creates snapshot of original values
dataRowOriginalValues = departmentDataRow.OriginalValues;
dataRowOriginalValuesCount = dataRowOriginalValues.Count;
// 9. Call RejectChanges method to put row back in the state before modifications occurred
departmentDataRow.RejectChanges();
// 10. Verify that the snapshot of original values is empty
dataRowOriginalValues = departmentDataRow.OriginalValues;
dataRowOriginalValuesCount = dataRowOriginalValues.Count;
// 11. Modify row data again to put it into Modified state
departmentDataRow["Name"] = "Reception";
// 12. Verify that the snapshot of original values contains data
// because the modification of any value of row creates snapshot of original values
dataRowOriginalValues = departmentDataRow.OriginalValues;
dataRowOriginalValuesCount = dataRowOriginalValues.Count;
// 13. Call AcceptChanges method to put row into Unchanged state
departmentDataRow.AcceptChanges();
// 14. Verify that the snapshot of original values is empty
// because the AcceptChanges method removes the snapshot of original values
dataRowOriginalValues = departmentDataRow.OriginalValues;
dataRowOriginalValuesCount = dataRowOriginalValues.Count;
// 15. Call Delete method to put row into deleted state
departmentDataRow.Delete();
// 16. Verify that the snapshot of original values contains data
// because the Delete method creates snapshot of original values
dataRowOriginalValues = departmentDataRow.OriginalValues;
dataRowOriginalValuesCount = dataRowOriginalValues.Count;
Table of Content POCO DataSet API References POCO DataSet Types DataRow 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.