SqlSyncProvider Clase

Representa un proveedor de sincronización que se comunica con una base de datos de SQL Server y aísla otros componentes de Sync Framework de la implementación concreta de la base de datos.

Esta API no es compatible con CLS. 

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

Sintaxis

'Declaración
<CLSCompliantAttribute(False)> _
Public Class SqlSyncProvider _
    Inherits RelationalSyncProvider
'Uso
Dim instance As SqlSyncProvider
[CLSCompliantAttribute(false)]
public class SqlSyncProvider : RelationalSyncProvider
[CLSCompliantAttribute(false)]
public ref class SqlSyncProvider : public RelationalSyncProvider
[<CLSCompliantAttribute(false)>]
type SqlSyncProvider =  
    class
        inherit RelationalSyncProvider
    end
public class SqlSyncProvider 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 tres sesiones de sincronización diferentes: la primera entre el servidor y el cliente de SQL Server, la segunda entre el cliente de SQL Server y uno de los clientes de SQL Server Compact, y la tercera 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.SqlServer..::..SqlSyncProvider

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

SqlSyncProvider Miembros

Microsoft.Synchronization.Data.SqlServer Espacio de nombres