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.ObservableData
Assembly: PocoDataSet.ObservableData.dll
// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create Department observable table
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
// 3. Add tow observable data rows in Unchanged state to Department observable table
IObservableDataRow departmentObservableDataRow1 = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow1["Id"] = 1;
departmentObservableDataRow1["Name"] = "Marketing";
departmentObservableDataRow1.AcceptChanges();
IObservableDataRow departmentObservableDataRow2 = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow2["Id"] = 2;
departmentObservableDataRow2["Name"] = "Reception";
departmentObservableDataRow2.AcceptChanges();
// 4. Try to read the original value before any modification or deletion.
// No snapshot exists yet, so the method returns false.
object? departmentName = null;
departmentObservableDataRow1.TryGetOriginalValue("Name", out departmentName);
departmentObservableDataRow2.TryGetOriginalValue("Name", out departmentName);
// 6. Call Delete method to put the first row into Deleted state
departmentObservableDataRow1.Delete();
// 7. Update value of the second row to put it into Modified state
departmentObservableDataRow2["Name"] = "HR";
// 8. Call TryGetOriginalValue method to get cached "Marketing" value for the Name column
bool hasOriginalName1 = departmentObservableDataRow1.TryGetOriginalValue("Name", out departmentName);
// 9. Call TryGetOriginalValue method to get cached "Reception" value for the Name column
bool hasOriginalName2 = departmentObservableDataRow2.TryGetOriginalValue("Name", out departmentName);
Table of Content POCO DataSet API References ObservablePOCO DataSet Types ObservableDataRow 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.