SqlCeSyncProvider 类

封装与客户端通信的 SQL Server Compact 同步提供程序并将同步控制器与客户端数据库的特定实现屏蔽开来。

此类不符合 CLS。  

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

语法

声明
<CLSCompliantAttribute(False)> _
Public Class SqlCeSyncProvider
    Inherits RelationalSyncProvider
用法
Dim instance As SqlCeSyncProvider
[CLSCompliantAttribute(false)] 
public class SqlCeSyncProvider : RelationalSyncProvider
[CLSCompliantAttribute(false)] 
public ref class SqlCeSyncProvider : public RelationalSyncProvider
/** @attribute CLSCompliantAttribute(false) */ 
public class SqlCeSyncProvider extends RelationalSyncProvider
CLSCompliantAttribute(false) 
public class SqlCeSyncProvider extends RelationalSyncProvider

备注

同步提供程序的主要活动如下所示:

  • 存储与对等方中启用了同步的表有关的信息。

  • 使应用程序能够检索自上次同步以来在数据库中发生的变更。

  • 将增量变更应用于数据库。

  • 检测发生冲突的变更。

示例

下面的代码示例为三个不同的同步会话实例化提供程序:这三个同步会话分别在服务器和 SQL Server 客户端之间、SQL Server 客户端和 SQL Server Compact 客户端之一之间以及服务器与另一个 SQL Server Compact 客户端之间。通过使用数据库快照对其中一个 SQL Server Compact 客户端进行初始化。若要在完整示例上下文中查看此代码,请参见如何配置和执行协作同步 (SQL Server)

SampleSyncOrchestrator syncOrchestrator;
SyncOperationStatistics syncStats;

// Data is downloaded from the server to the SQL Server client.
syncOrchestrator = new SampleSyncOrchestrator(
    new SqlSyncProvider("filtered_customer", clientSqlConn, null, "Sync"),
    new SqlSyncProvider("filtered_customer", serverConn, null, "Sync")
    );
syncStats = syncOrchestrator.Synchronize();
syncOrchestrator.DisplayStats(syncStats, "initial");

// Data is downloaded from the SQL Server client to the 
// first SQL Server Compact client.
syncOrchestrator = new SampleSyncOrchestrator(
    new SqlCeSyncProvider("filtered_customer", clientSqlCe1Conn, "Sync"),
    new SqlSyncProvider("filtered_customer", clientSqlConn, null, "Sync")
    );
syncStats = syncOrchestrator.Synchronize();
syncOrchestrator.DisplayStats(syncStats, "initial");

// Create a snapshot from the SQL Server Compact database, which will be used to
// initialize a second Compact database. Again, this database could be provisioned
// by retrieving scope information from another database, but we want to 
// demonstrate the use of snapshots, which provide a convenient deployment
// mechanism for Compact databases.
SqlCeSyncStoreSnapshotInitialization syncStoreSnapshot = new SqlCeSyncStoreSnapshotInitialization("Sync");
syncStoreSnapshot.GenerateSnapshot(clientSqlCe1Conn, "SyncSampleClient2.sdf");

// The new SQL Server Compact client synchronizes with the server, but
// no data is downloaded because the snapshot already contains 
// all of the data from the first Compact database.
syncOrchestrator = new SampleSyncOrchestrator(
    new SqlSyncProvider("filtered_customer", serverConn, null, "Sync"),
    new SqlCeSyncProvider("filtered_customer", clientSqlCe2Conn, "Sync")
    );
syncStats = syncOrchestrator.Synchronize();
syncOrchestrator.DisplayStats(syncStats, "initial");
Dim syncOrchestrator As SampleSyncOrchestrator
Dim syncStats As SyncOperationStatistics

' Data is downloaded from the server to the SQL Server client. 
syncOrchestrator = New SampleSyncOrchestrator( _
    New SqlSyncProvider("filtered_customer", clientSqlConn, Nothing, "Sync"), _
    New SqlSyncProvider("filtered_customer", serverConn, Nothing, "Sync"))
syncStats = syncOrchestrator.Synchronize()
syncOrchestrator.DisplayStats(syncStats, "initial")

' Data is downloaded from the SQL Server client to the 
' first SQL Server Compact client. 
syncOrchestrator = New SampleSyncOrchestrator( _
    New SqlCeSyncProvider("filtered_customer", clientSqlCe1Conn, "Sync"), _
    New SqlSyncProvider("filtered_customer", clientSqlConn, Nothing, "Sync"))
syncStats = syncOrchestrator.Synchronize()
syncOrchestrator.DisplayStats(syncStats, "initial")

' Create a snapshot from the SQL Server Compact database, which will be used to 
' initialize a second Compact database. Again, this database could be provisioned 
' by retrieving scope information from another database, but we want to 
' demonstrate the use of snapshots, which provide a convenient deployment 
' mechanism for Compact databases. 
Dim syncStoreSnapshot As New SqlCeSyncStoreSnapshotInitialization("Sync")
syncStoreSnapshot.GenerateSnapshot(clientSqlCe1Conn, "SyncSampleClient2.sdf")

' The new SQL Server Compact client synchronizes with the server, but 
' no data is downloaded because the snapshot already contains 
' all of the data from the first Compact database. 
syncOrchestrator = New SampleSyncOrchestrator( _
    New SqlSyncProvider("filtered_customer", serverConn, Nothing, "Sync"), _
    New SqlCeSyncProvider("filtered_customer", clientSqlCe2Conn, "Sync"))
syncStats = syncOrchestrator.Synchronize()
syncOrchestrator.DisplayStats(syncStats, "initial")

继承层次结构

System.Object
   Microsoft.Synchronization.SyncProvider
     Microsoft.Synchronization.KnowledgeSyncProvider
       Microsoft.Synchronization.Data.RelationalSyncProvider
        Microsoft.Synchronization.Data.SqlServerCe.SqlCeSyncProvider

线程安全

此类型的所有公共静态(在 Visual Basic 中共享 )成员都是线程安全的。不保证任何实例成员的线程安全。

请参阅

参考

SqlCeSyncProvider 成员
Microsoft.Synchronization.Data.SqlServerCe 命名空间