ConflictResolver 属性

获取客户端同步提供程序的 SyncConflictResolver 对象,该对象用于确定发生冲突时要执行的操作。

命名空间:  Microsoft.Synchronization.Data.SqlServerCe
程序集:  Microsoft.Synchronization.Data.SqlServerCe(在 Microsoft.Synchronization.Data.SqlServerCe.dll 中)

语法

声明
Public ReadOnly Property ConflictResolver As SyncConflictResolver
    Get
用法
Dim instance As SqlCeClientSyncProvider
Dim value As SyncConflictResolver

value = instance.ConflictResolver
public SyncConflictResolver ConflictResolver { get; }
public:
property SyncConflictResolver^ ConflictResolver {
    SyncConflictResolver^ get ();
}
member ConflictResolver : SyncConflictResolver
function get ConflictResolver () : SyncConflictResolver

属性值

类型:Microsoft.Synchronization.Data. . :: . .SyncConflictResolver
一个 SyncConflictResolver 对象,该对象确定发生冲突时要执行的操作。

注释

SqlCeClientSyncProvider 包括一个 ConflictResolver 属性,该属性可用来解决客户端上的冲突。对于每种类型的冲突,都可以设置 ResolveAction 枚举中的一个值:

不需要为每种类型的冲突均设置 ConflictResolver。通过处理 ApplyChangeFailed 事件,可以像在服务器上一样解决冲突。但是,ConflictResolver 属性为在客户端上指定冲突解决选项提供了一条简单的途径。有关更多信息,请参见如何处理数据冲突和错误

示例

下面的代码示例为客户端同步提供程序可能遇到每种冲突类型设置解决操作。若要在完整示例上下文中查看此代码,请参见如何处理数据冲突和错误

this.ConflictResolver.ClientDeleteServerUpdateAction = ResolveAction.ServerWins;            
this.ConflictResolver.ClientUpdateServerDeleteAction = ResolveAction.ClientWins;
//If any of the following conflicts or errors occur, the ApplyChangeFailed
//event is raised.
this.ConflictResolver.ClientInsertServerInsertAction = ResolveAction.FireEvent;
this.ConflictResolver.ClientUpdateServerUpdateAction = ResolveAction.FireEvent;
this.ConflictResolver.StoreErrorAction = ResolveAction.FireEvent;

//Log information for the ApplyChangeFailed event and handle any
//ResolveAction.FireEvent cases.
this.ApplyChangeFailed +=new EventHandler<ApplyChangeFailedEventArgs>(SampleClientSyncProvider_ApplyChangeFailed);
Me.ConflictResolver.ClientDeleteServerUpdateAction = ResolveAction.ServerWins
Me.ConflictResolver.ClientUpdateServerDeleteAction = ResolveAction.ClientWins
'If any of the following conflicts or errors occur, the ApplyChangeFailed
'event is raised.
Me.ConflictResolver.ClientInsertServerInsertAction = ResolveAction.FireEvent
Me.ConflictResolver.ClientUpdateServerUpdateAction = ResolveAction.FireEvent
Me.ConflictResolver.StoreErrorAction = ResolveAction.FireEvent

'Log information for the ApplyChangeFailed event and handle any
'ResolveAction.FireEvent cases.
AddHandler Me.ApplyChangeFailed, AddressOf SampleClientSyncProvider_ApplyChangeFailed

请参阅

参考

SqlCeClientSyncProvider类

SqlCeClientSyncProvider 成员

Microsoft.Synchronization.Data.SqlServerCe 命名空间