SqlCeSyncStoreSnapshotInitialization Class

Represents an existing SQL Server Compact database file that can be used to initialize another SQL Server Compact database for synchronization.

Inheritance Hierarchy

System.Object
  Microsoft.Synchronization.Data.SqlServerCe.SqlCeSyncStoreSnapshotInitialization

Namespace:  Microsoft.Synchronization.Data.SqlServerCe
Assembly:  Microsoft.Synchronization.Data.SqlServerCe (in Microsoft.Synchronization.Data.SqlServerCe.dll)

Syntax

'Declaration
Public Class SqlCeSyncStoreSnapshotInitialization _
    Implements IDisposable
'Usage
Dim instance As SqlCeSyncStoreSnapshotInitialization
public class SqlCeSyncStoreSnapshotInitialization : IDisposable
public ref class SqlCeSyncStoreSnapshotInitialization : IDisposable
type SqlCeSyncStoreSnapshotInitialization =  
    class
        interface IDisposable
    end
public class SqlCeSyncStoreSnapshotInitialization implements IDisposable

The SqlCeSyncStoreSnapshotInitialization type exposes the following members.

Constructors

  Name Description
Public method SqlCeSyncStoreSnapshotInitialization() Initializes a new instance of the SqlCeSyncStoreSnapshotInitialization class by using default values.
Public method SqlCeSyncStoreSnapshotInitialization(String) Initializes a new instance of the SqlCeSyncStoreSnapshotInitialization class for the specified object prefix.
Public method SqlCeSyncStoreSnapshotInitialization(SyncIdFormatGroup, String) Initializes a new instance of the SqlCeSyncStoreSnapshotInitialization class for the specified ID format and object prefix.

Top

Properties

  Name Description
Public property ObjectPrefix Gets or sets the optional prefix that is used to identify objects that Sync Framework creates.

Top

Methods

  Name Description
Public method Dispose() Releases all resources that are used by the SqlCeSyncStoreSnapshotInitialization object.
Protected method Dispose(Boolean) Releases the unmanaged resources used by the SqlCeSyncStoreSnapshotInitialization object and optionally releases the managed resources.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GenerateSnapshot Generates a snapshot of an existing SQL Server Compact database file that can be used to initialize another SQL Server Compact database for synchronization.
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Public method InitializeSnapshot Updates metadata for a snapshot so that the snapshot can be used by a new synchronization node.
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)

Top

Events

  Name Description
Public event BeginSnapshotInitialization Occurs when InitializeSnapshot is called.
Public event EndSnapshotInitialization Occurs when all tables for a particular scope in the snapshot have been initialized.

Top

Remarks

Snapshot initialization is designed to reduce the time required to initialize a client database. After one client database has been initialized by using full initialization, subsequent databases can be initialized by using a snapshot of this first client database. A snapshot is a specially-prepared SQL Server Compact database that contains table schema, data (optional), and change-tracking infrastructure. Copy this snapshot to each client that requires it. During the first synchronization session for a client, client-specific metadata is updated, and any changes that occurred since the snapshot was created are downloaded to the client database.

Important

Snapshots should be generated only when there is no activity in the SQL Server Compact database. Concurrent operations of any type are not supported during snapshot generation.

Examples

The following code example generates a snapshot named SyncSampleClient2.sdf from the SyncSampleClient1.sdf database. The code then synchronizes SyncSampleClient2.sdf with the server database. To view this code in the context of a complete example, see How To: Execute Database Synchronization (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")

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Synchronization.Data.SqlServerCe Namespace