SqlCeSyncProvider-Klasse
Kapselt einen Synchronisierungsanbieter für SQL Server Compact, der mit dem Client kommuniziert und den Synchronisierungsorchestrator von der spezifischen Implementierung der Clientdatenbank abschirmt.
Diese API ist nicht CLS-kompatibel.
Namespace: Microsoft.Synchronization.Data.SqlServerCe
Assembly: Microsoft.Synchronization.Data.SqlServerCe (in Microsoft.Synchronization.Data.SqlServerCe.dll)
Syntax
'Declaration
<CLSCompliantAttribute(False)> _
Public Class SqlCeSyncProvider _
Inherits RelationalSyncProvider
'Usage
Dim instance As SqlCeSyncProvider
[CLSCompliantAttribute(false)]
public class SqlCeSyncProvider : RelationalSyncProvider
[CLSCompliantAttribute(false)]
public ref class SqlCeSyncProvider : public RelationalSyncProvider
[<CLSCompliantAttribute(false)>]
type SqlCeSyncProvider =
class
inherit RelationalSyncProvider
end
public class SqlCeSyncProvider extends RelationalSyncProvider
Hinweise
Ein Synchronisierungsanbieter hat im Wesentlichen die folgenden Aufgaben:
Speichern von Informationen zu Tabellen auf dem Peer, für die Synchronisierung aktiviert ist
Anwendungen ermöglichen, Änderungen abzurufen, die seit der letzten Synchronisierung in der Datenbank vorgenommen wurden
Übernehmen inkrementeller Änderungen für die Datenbank
Erkennen miteinander in Konflikt stehender Änderungen
Beispiele
Im folgenden Codebeispiel werden Anbieter für drei verschiedene Synchronisierungssitzungen instanziiert: zwischen einem Server und einem SQL Server-Client, zwischen dem Server und dem SQL Server-Client, zwischen dem SQL Server-Client und einem der SQL Server Compact-Clients sowie zwischen dem Server und dem anderen SQL Server Compact-Client. Einer der SQL Server Compact-Clients wird mithilfe einer Datenbankmomentaufnahme initialisiert. Eine Darstellung dieses Codes im Kontext eines vollständigen Beispiels finden Sie unter Vorgehensweise: Konfigurieren und Ausführen der Datenbanksynchronisierung (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")
Vererbungshierarchie
System. . :: . .Object
Microsoft.Synchronization. . :: . .SyncProvider
Microsoft.Synchronization. . :: . .KnowledgeSyncProvider
Microsoft.Synchronization.Data. . :: . .RelationalSyncProvider
Microsoft.Synchronization.Data.SqlServerCe..::..SqlCeSyncProvider
Threadsicherheit
Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.