共用方式為


SqlCeSyncStoreSnapshotInitialization 類別

表示可用來初始化其他 SQL Server Compact 資料庫以便進行同步處理的現有 SQL Server Compact 資料庫檔案。

命名空間:  Microsoft.Synchronization.Data.SqlServerCe
組件:  Microsoft.Synchronization.Data.SqlServerCe (在 Microsoft.Synchronization.Data.SqlServerCe.dll 中)

語法

'宣告
Public Class SqlCeSyncStoreSnapshotInitialization _
    Implements IDisposable
'用途
Dim instance As SqlCeSyncStoreSnapshotInitialization
public class SqlCeSyncStoreSnapshotInitialization : IDisposable
public ref class SqlCeSyncStoreSnapshotInitialization : IDisposable
type SqlCeSyncStoreSnapshotInitialization =  
    class
        interface IDisposable
    end
public class SqlCeSyncStoreSnapshotInitialization implements IDisposable

備註

快照集初始化的用意是要減少初始化用戶端資料庫所需的時間。當已經使用完整初始化來初始化一個用戶端資料庫之後,後續的資料庫可以使用第一個用戶端資料庫的「快照集」來初始化。快照集是特別準備的 SQL Server Compact 資料庫,其中包含資料表結構描述、資料 (選擇性) 和變更追蹤基礎結構。請將這個快照集複製到需要它的每個用戶端。在用戶端的第一個同步處理工作階段期間,將會更新用戶端特有的中繼資料,而且在建立快照集之後所發生的所有變更都會下載到用戶端資料庫。

重要注意事項重要事項

只有當 SQL Server Compact 資料庫中沒有任何活動時,才應該產生快照集。在快照集產生期間,並不支援任何型別的並行作業。

範例

下列程式碼範例會根據 SyncSampleClient1.sdf 資料庫產生名為 SyncSampleClient2.sdf 的快照集。然後,此程式碼會同步處理 SyncSampleClient2.sdf 與伺服器資料庫。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:設定及執行資料庫同步處理 (SQL Server)

// 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");
' 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.Data.SqlServerCe..::..SqlCeSyncStoreSnapshotInitialization

執行緒安全性

這個類型的任何公用static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員都可以是安全執行緒。

請參閱

參考

SqlCeSyncStoreSnapshotInitialization 成員

Microsoft.Synchronization.Data.SqlServerCe 命名空間