同步服务Ado.net冲突解决方案

时间:2022-04-14 09:37:34

is it possible to solve conflicts on client side with sync services for ado.net? for example, with Client Insert Server Insert, updating client's table id (on client side) , tks

是否有可能通过ado.net的同步服务解决客户端的冲突?例如,使用客户端插入服务器插入,更新客户端的表ID(在客户端),tks

1 个解决方案

#1


While on the server side you can do:

在服务器端,您可以执行以下操作:

Partial Public Class NorthwindCacheServerSyncProvider
    Private Sub ApplyChangeFailedEvent(…) Handles Me.ApplyChangeFailed
        Dim clientChanges As DataTable = e.Conflict.ClientChange
        Dim serverChanges As DataTable = e.Conflict.ServerChange
        ' Code to resolve conflict 
           If (clientChanges.Rows(0)("ModifiedDate") > _
               serverChanges.Rows(0)("ModifiedDate") Then e.Action =                      ApplyAction.RetryWithForceWrite 
           End If         

You cant do this on the client, but, you can intercept the applying changes event and take appropriate action, like this...

您无法在客户端上执行此操作,但是,您可以拦截应用更改事件并采取适当的操作,例如......

Partial Public Class NorthwindCacheClientSyncProvider
    Private Sub ApplyingChangesEvent(…) Handles Me.ApplyingChanges
        Dim clientChanges As DataSet = e.Changes

#1


While on the server side you can do:

在服务器端,您可以执行以下操作:

Partial Public Class NorthwindCacheServerSyncProvider
    Private Sub ApplyChangeFailedEvent(…) Handles Me.ApplyChangeFailed
        Dim clientChanges As DataTable = e.Conflict.ClientChange
        Dim serverChanges As DataTable = e.Conflict.ServerChange
        ' Code to resolve conflict 
           If (clientChanges.Rows(0)("ModifiedDate") > _
               serverChanges.Rows(0)("ModifiedDate") Then e.Action =                      ApplyAction.RetryWithForceWrite 
           End If         

You cant do this on the client, but, you can intercept the applying changes event and take appropriate action, like this...

您无法在客户端上执行此操作,但是,您可以拦截应用更改事件并采取适当的操作,例如......

Partial Public Class NorthwindCacheClientSyncProvider
    Private Sub ApplyingChangesEvent(…) Handles Me.ApplyingChanges
        Dim clientChanges As DataSet = e.Changes