Replace / Reload Result Sets – Quick Start
For new searches or when you intentionally want to discard local edits, use Reload / Replace.
This workflow clears the current rows and replaces them with refreshed rows, ending in a clean baseline
where everything is Unchanged.
AcceptChanges() so the result becomes a clean baseline.IObservableDataSet.DoReplaceMerge method.Unchanged.Assuming observable data set is used for UI binding, for example:
// 1. Create observable dataset
IObservableDataSet boundObservableDataSet = new ObservableDataSet();
// 2. Add Department table to the observable dataset
IObservableDataTable departmentObservableDataTable = boundObservableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
// 3. Add a row to the Department table (data row state is Added)
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 1;
departmentObservableDataRow["Name"] = "Sales";
// 4. Add another row to the Department table, the values of which user hadn't cahnged (data row state is Unchanged)
IObservableDataRow departmentObservableDataRow = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow["Id"] = 2;
departmentObservableDataRow["Name"] = "Emergency";
departmentObservableDataRow.AcceptChanges();
// The following line is a pseudo-code example of how UI can be bound to the observable data set.
// The actual binding code depends on the UI framework and is not part of POCO DataSet.
somePage.DataContext = boundObservableDataSet;
Assuming user clicked on Refresh button asking to refresh bound data. The following code imitates the server response.
// 1. Create refreshed dataset
IDataSet refreshedDataSet = DataSetFactory.CreateDataSet();
// 2. Add Department table to the refreshed dataset
IDataTable departmentRefreshedDataTable = refreshedDataSet.AddNewTable("Department");
departmentRefreshedDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentRefreshedDataTable.AddColumn("Name", DataTypeNames.STRING);
// 3. Add two rows to the Department table which imitate changed data in the database
IDataRow departmentRefreshedDataRow = departmentRefreshedDataTable.AddNewRow();
departmentRefreshedDataRow["Id"] = 1;
departmentRefreshedDataRow["Name"] = "Sales and Marketing";
departmentRefreshedDataRow = departmentRefreshedDataTable.AddNewRow();
departmentRefreshedDataRow["Id"] = 2;
departmentRefreshedDataRow["Name"] = "Emergency Department";
// 4. Mark all rows as Unchanged to indicate they are clean server values
refreshedDataSet.AcceptChanges();
Call IObservableDataSet.DoReplaceMerge method to discard all local changes and replace all local data by refreshed snapshot:
IObservableMergeOptions observableMergeOptions = new ObservableMergeOptions();
boundObservableDataSet.DoReplaceMerge(refreshedDataSet, observableMergeOptions);
// Observe that the name of the Sales department is updated to "Sales and Marketing"
string nameOfSalesDepartment = (string)currentDepartment.Rows[0]["Name"];
// Observe that the name of the Emergency department is updated to "Emergency Department"
string nameOfEmergencyDepartment = (string)currentDepartment.Rows[1]["Name"];
Table of Content POCO DataSet Quick Start
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.