Partager via


Classe SqlCeSyncProvider

Encapsule un fournisseur de synchronisation pour SQL Server Compact qui communique avec le client et protège l'orchestrateur de synchronisation contre l'implémentation spécifique de la base de données client.

Cette classe n'est pas conforme CLS.  

Espace de noms: Microsoft.Synchronization.Data.SqlServerCe
Assembly: Microsoft.Synchronization.Data.SqlServerCe (dans microsoft.synchronization.data.sqlserverce.dll)

Syntaxe

'Déclaration
<CLSCompliantAttribute(False)> _
Public Class SqlCeSyncProvider
    Inherits RelationalSyncProvider
'Utilisation
Dim instance As SqlCeSyncProvider
[CLSCompliantAttribute(false)] 
public class SqlCeSyncProvider : RelationalSyncProvider
[CLSCompliantAttribute(false)] 
public ref class SqlCeSyncProvider : public RelationalSyncProvider
/** @attribute CLSCompliantAttribute(false) */ 
public class SqlCeSyncProvider extends RelationalSyncProvider
CLSCompliantAttribute(false) 
public class SqlCeSyncProvider extends RelationalSyncProvider

Notes

Les principales activités d'un fournisseur de synchronisation sont les suivantes :

  • Stocke des informations sur les tables de l'homologue qui sont activées pour la synchronisation.

  • Permet aux applications de récupérer les modifications intervenues dans la base de données depuis la dernière synchronisation.

  • Applique les modifications incrémentielles à la base de données.

  • Détecte les modifications conflictuelles.

Exemple

L'exemple de code suivant instancie des fournisseurs pour trois sessions de synchronisation différentes : entre un serveur et un client SQL Server ; entre le serveur et le client SQL Server ;entre le client SQL Server et l'un des clients SQL Server Compact ; et entre le serveur et l'autre client SQL Server Compact. L'un des clients SQL Server Compact est initialisé à l'aide d'un instantané de base de données. Pour afficher ce code dans le contexte d'un exemple complet, consultez Procédure : configurer et exécuter la synchronisation collaborative (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")

Hiérarchie d'héritage

System.Object
   Microsoft.Synchronization.SyncProvider
     Microsoft.Synchronization.KnowledgeSyncProvider
       Microsoft.Synchronization.Data.RelationalSyncProvider
        Microsoft.Synchronization.Data.SqlServerCe.SqlCeSyncProvider

Sécurité des threads

Tous les membres publics statiques (Partagés en Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi

Référence

Membres SqlCeSyncProvider
Espace de noms Microsoft.Synchronization.Data.SqlServerCe