Thanks Jesse,
I was able to get it to work, but perhaps not in the best way.
The example does not do "last writer wins" nor refer to it. I added my own "date_mod" columns to the appropriate tables, which are updated by trigger. The code fragment for enforcing "last writer wins" is:
private void dbProvider_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
{
DataTable conflictingRemoteChange = e.Conflict.RemoteChange;
DataTable conflictingLocalChange = e.Conflict.LocalChange;
if (e.Conflict.Type == DbConflictType.LocalUpdateRemoteUpdate)
{
Object oLocalTime = conflictingLocalChange.Rows[0]["date_mod"];
Object oRemoteTime = conflictingRemoteChange.Rows[0]["date_mod"];
if (oLocalTime != null && oRemoteTime != null)
{
DateTime localTime = (DateTime)oLocalTime;
DateTime remoteTime = (DateTime)oRemoteTime;
if (DateTime.Compare(localTime, remoteTime) < 0)
{
e.Action = ApplyAction.RetryWithForceWrite;
return;
}
}
}
e.Action = ApplyAction.Continue;
return;
I noticed, however, that the table [Sync].[MyTable_tracking], generated by the SqlSyncScopeProvisioning object, already contains a field called last_change_datetime, and it is populated properly. This field, however, is not copied over
to the data table that is provided to the DbApplyChangeFailedEventArgs argument. Is there any easy way to access it?
Thanks,
Charlie