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 与服务器数据库同步。若要在完整示例上下文中查看此代码,请参见如何配置和执行数据库同步 (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) 都是线程安全的。不保证所有实例成员都是线程安全的。