DoRefreshMergeIfNoChangesExist Method

Overview

The DoRefreshMergeIfNoChangesExist method refreshes the current data set from a server snapshot only when the current data set contains no pending local changes.

If any row in any merged table is not Unchanged, the merge throws an InvalidOperationException to protect local work.

Declaration

/// <summary>
/// Dose RefreshIfNoChangesExist merge
/// </summary>
/// <param name="currentDataSet">Current data set</param>
/// <param name="refreshedDataSet">Refreshed data set</param>
/// <param name="mergeOptions">Merge options</param>
public static void DoRefreshMergeIfNoChangesExist(this IDataSet? currentDataSet, IDataSet refreshedDataSet, IMergeOptions mergeOptions)

Namespace and Assembly

Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll

Behavior

Usage Example

// CURRENT: clean client-side snapshot.
IDataSet current = DataSetFactory.CreateDataSet();

IDataTable department = current.AddNewTable("Department");
department.AddColumn("Id", DataTypeNames.INT32, isNullable: false, isPrimaryKey: true);
department.AddColumn("Name", DataTypeNames.STRING);

IDataRow d1 = department.AddNewRow();
d1["Id"] = 1;
d1["Name"] = "Old Name";
current.AcceptChanges(); // IMPORTANT: make the dataset clean (rows become Unchanged)

// REFRESHED: server snapshot (Id=1 has updated Name).
IDataSet refreshed = DataSetFactory.CreateDataSet();

IDataTable rDepartment = refreshed.AddNewTable("Department");
rDepartment.AddColumn("Id", DataTypeNames.INT32, isNullable: false, isPrimaryKey: true);
rDepartment.AddColumn("Name", DataTypeNames.STRING);

IDataRow r1 = rDepartment.AddNewRow();
r1["Id"] = 1;
r1["Name"] = "New Name From Server";
refreshed.AcceptChanges();

IMergeOptions options = new MergeOptions();

// Act: refresh merge (allowed because CURRENT has no pending changes).
current.DoRefreshMergeIfNoChangesExist(refreshed, options);

// Assert: row refreshed
string name = department.Rows[0].GetDataFieldValue<string>("Name"); // "New Name From Server"

// If CURRENT had pending changes, DoRefreshMergeIfNoChangesExist would throw.

Notes

 

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.