SqlCeSyncProvider Clase

Encapsula un proveedor de sincronización para SQL Server Compact que se comunica con el cliente y aísla el organizador de la sincronización de la implementación concreta de la base de datos cliente.

Esta API no es compatible con CLS. 

Espacio de nombres:  Microsoft.Synchronization.Data.SqlServerCe
Ensamblado:  Microsoft.Synchronization.Data.SqlServerCe (en Microsoft.Synchronization.Data.SqlServerCe.dll)

Sintaxis

'Declaración
<CLSCompliantAttribute(False)> _
Public Class SqlCeSyncProvider _
    Inherits RelationalSyncProvider
'Uso
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

Notas

Las actividades principales de un proveedor de sincronización son:

  • Almacena información de las tablas del elemento del mismo nivel que están habilitadas para sincronización.

  • Permite a las aplicaciones recuperar los cambios producidos en la base de datos desde la última sincronización.

  • Aplica los cambios incrementales a la base de datos.

  • Detecta los cambios en conflicto.

Ejemplos

En el ejemplo de código siguiente se crean instancias de los proveedores en cuatro sesiones de sincronización diferentes: la primera entre un servidor y un cliente de SQL Server, la segunda entre el servidor y el cliente de SQL Server, la tercera entre el cliente de SQL Server y uno de los clientes de SQL Server Compact, y la cuarta entre el servidor y el otro cliente de SQL Server Compact. Uno de los clientes de SQL Server Compact se inicializa utilizando una instantánea de base de datos. Para consultar este código en el contexto de un ejemplo completo, vea Configurar y ejecutar la sincronización de base de datos (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")

Jerarquía de herencia

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

Seguridad para subprocesos

Todos los miembros públicos static (Shared en Visual Basic) de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Vea también

Referencia

SqlCeSyncProvider Miembros

Microsoft.Synchronization.Data.SqlServerCe Espacio de nombres