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 用戶端與其中一個 SQL Server Compact 用戶端之間,以及在伺服器與其他 SQL Server Compact 用戶端之間。其中一個 SQL Server Compact 用戶端是使用資料庫快照集來初始化。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:設定及執行共同作業同步處理 (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 命名空間