TryGetOriginalValue Method
The TryGetOriginalValue method allows you to get the baseline (original) value
for the specified column from the row’s original-values snapshot, if such a snapshot exists.
Original values are captured automatically when an Unchanged row
is modified for the first time or when the Delete method is called.
The method returns true when a snapshot exists and contains the specified column;
otherwise it returns false and outputs null.
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. Call the AcceptChanges method to set row state into Unchanged
departmentDataRow.AcceptChanges();
// 5. Try to read the original value before any modification or deletion.
// No snapshot exists yet, so the method returns false.
object? departmentName = null;
departmentDataRow.TryGetOriginalValue("Name", out departmentName);
// 6. Call Delete method to put row into Deleted state
departmentDataRow.Delete();
// 7. Call TryGetOriginalValue method to get cached "Emergency" value for the Name column
bool hasOriginalName = departmentDataRow.TryGetOriginalValue("Name", out departmentName);
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.