Freigeben über


SqlCeSyncStoreSnapshotInitialization-Klasse

Stellt eine vorhandene SQL Server Compact-Datenbankdatei dar, mit der eine andere SQL Server Compact-Datenbank für die Synchronisierung initialisiert werden kann.

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

Hinweise

Die Momentaufnahmeninitialisierung dient zur Verkürzung der Zeitspanne für das Initialisieren einer Clientdatenbank. Nachdem eine Clientdatenbank mithilfe einer vollständigen Initialisierung initialisiert wurde, können weitere Datenbanken mithilfe einer Momentaufnahme dieser ersten Clientdatenbank initialisiert werden. Bei einer Momentaufnahme handelt es sich um eine entsprechend vorbereitete SQL Server Compact-Datenbank, die Tabellenschemas, Daten (optional) und die Infrastruktur für die Änderungsnachverfolgung enthält. Kopieren Sie diese Momentaufnahme auf alle Clients, die diese benötigen. Bei der ersten Synchronisierungssitzung für einen Client werden clientspezifische Metadaten aktualisiert und alle seit dem Erstellen der Momentaufnahme aufgetretenen Änderungen in die Clientdatenbank heruntergeladen.

Wichtig

Momentaufnahmen sollten nur erzeugt werden, wenn die SQL Server Compact-Datenbank keine Aktivität aufweist. Gleichzeitige Vorgänge jedweder Art werden bei der Momentaufnahmenerstellung nicht unterstützt.

Beispiele

Im folgenden Codebeispiel wird anhand der SyncSampleClient1.sdf-Datenbank eine Momentaufnahme mit dem Namen SyncSampleClient2.sdf erstellt. Dann synchronisiert der Code SyncSampleClient2.sdf mit der Serverdatenbank. Eine Darstellung dieses Codes im Kontext eines vollständigen Beispiels finden Sie unter Vorgehensweise: Konfigurieren und Ausführen der Datenbanksynchronisierung (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")

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

SqlCeSyncStoreSnapshotInitialization-Member

Microsoft.Synchronization.Data.SqlServerCe-Namespace