Export (0) Print
Expand All

SqlCeSyncProvider Class

Encapsulates a synchronization provider for SQL Server Compact that communicates with the client and shields the synchronization orchestrator from the specific implementation of the client database.

This API is not CLS-compliant. 

Namespace:  Microsoft.Synchronization.Data.SqlServerCe
Assembly:  Microsoft.Synchronization.Data.SqlServerCe (in Microsoft.Synchronization.Data.SqlServerCe.dll)

[CLSCompliantAttribute(false)]
public class SqlCeSyncProvider : RelationalSyncProvider

The SqlCeSyncProvider type exposes the following members.

  NameDescription
Public methodSqlCeSyncProvider()Initializes a new instance of the SqlCeSyncProvider class by using default values.
Public methodSqlCeSyncProvider(String, SqlCeConnection)Initializes a new instance of the SqlCeSyncProvider class for the specified scope name and connection.
Public methodSqlCeSyncProvider(String, SqlCeConnection, String)Initializes a new instance of the SqlCeSyncProvider class for the specified scope name, connection, and synchronization object prefix.
Top

  NameDescription
Public propertyBatchingDirectoryGets or sets the directory in which batch files are spooled to disk. (Inherited from RelationalSyncProvider.)
Public propertyCleanupBatchingDirectoryGets or sets whether to clean up batching files after the changes in the files have been applied to the destination. (Inherited from RelationalSyncProvider.)
Public propertyConfigurationNot implemented by RelationalSyncProvider. An exception of type NotSupportedException is thrown if you attempt to access this property. (Inherited from RelationalSyncProvider.)
Public propertyConnectionGets or sets the IDbConnection object that is used to connect to the client database. (Overrides RelationalSyncProvider.Connection.)
Public propertyDestinationCallbacksGets an object that a synchronization application can use to register to receive notification of events that occur during synchronization. (Inherited from KnowledgeSyncProvider.)
Public propertyIdFormatsGets a SyncIdFormatGroup object that is used to identify entities in a synchronization session. (Inherited from RelationalSyncProvider.)
Public propertyMemoryDataCacheSizeGets or sets the maximum amount of memory (in KB) that Sync Framework uses to cache changes before spooling those changes to disk. (Inherited from RelationalSyncProvider.)
Public propertyObjectPrefixGets or sets the optional prefix that is used to identify objects that Sync Framework creates.
Public propertyScopeNameGets or sets the name of the scope to synchronize. (Overrides RelationalSyncProvider.ScopeName.)
Public propertySyncProviderPositionGets or sets a SyncProviderPosition enumeration value that represents whether a provider is associated with the local or remote database. (Inherited from RelationalSyncProvider.)
Top

  NameDescription
Public methodBeginSessionCalled by the SyncOrchestrator to indicate that a synchronization session has started. (Overrides RelationalSyncProvider.BeginSession(SyncProviderPosition, SyncSessionContext).)
Protected methodCreateApplicationTransactionCreates a read-committed transaction over which to apply changes to the SQL Server Compact database. (Overrides RelationalSyncProvider.CreateApplicationTransaction().)
Protected methodCreateEnumerationTransactionCreates a read-committed transaction over which to enumerate changes from the SQL Server Compact database. (Overrides RelationalSyncProvider.CreateEnumerationTransaction().)
Public methodDispose()Releases all resources that are used by the RelationalSyncProvider. (Inherited from RelationalSyncProvider.)
Protected methodDispose(Boolean)Releases the unmanaged resources that are used by the SqlCeSyncProvider and optionally releases the managed resources. (Overrides RelationalSyncProvider.Dispose(Boolean).)
Public methodEndSessionCalled by the SyncOrchestrator object to indicate that a synchronization session has ended. (Inherited from RelationalSyncProvider.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetChangeBatchGets a batch of changes to synchronize when given batch size, destination knowledge, and change data retriever parameters. (Inherited from RelationalSyncProvider.)
Public methodGetFullEnumerationChangeBatchGets a batch of changes to synchronize when given batch size, lower bound, knowledge, and change data retriever parameters. (Inherited from RelationalSyncProvider.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetSyncBatchParametersGets the number of kilobytes of data that will be included in change batches, and the current knowledge for the synchronization scope. (Inherited from RelationalSyncProvider.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnApplyChangeFailedRaises the ApplyChangeFailed event that is inherited by this class. (Overrides RelationalSyncProvider.OnApplyChangeFailed(DbApplyChangeFailedEventArgs).)
Protected methodOnApplyingChangesRaises the ApplyingChanges event that is inherited by this class. (Overrides RelationalSyncProvider.OnApplyingChanges(DbApplyingChangesEventArgs, IDbTransaction).)
Protected methodOnApplyMetadataFailedRaises the ApplyMetadataFailed event that is inherited by this class. (Overrides RelationalSyncProvider.OnApplyMetadataFailed(ApplyMetadataFailedEventArgs, IDbTransaction).)
Protected methodOnChangesAppliedRaises the ChangesApplied event that is inherited by this class. (Overrides RelationalSyncProvider.OnChangesApplied(DbChangesAppliedEventArgs, IDbTransaction).)
Protected methodOnChangesSelectedRaises the ChangesSelected event. (Inherited from RelationalSyncProvider.)
Protected methodOnDbConnectionFailureRaises the DbConnectionFailure event. (Inherited from RelationalSyncProvider.)
Protected methodOnPeerOutdatedRaises the SyncPeerOutdated event. (Inherited from RelationalSyncProvider.)
Protected methodOnSelectingChangesRaises the SelectingChanges event. (Inherited from RelationalSyncProvider.)
Protected methodOnSyncProgressRaises the SyncProgress event that is inherited by this class. (Overrides RelationalSyncProvider.OnSyncProgress(DbSyncProgressEventArgs, IDbTransaction).)
Public methodProcessChangeBatchProcesses a batch of changes when given resolution policy, source changes, change data retriever, callback, and statistics parameters. (Inherited from RelationalSyncProvider.)
Public methodProcessFullEnumerationChangeBatchProcesses a batch of changes when given resolution policy, source changes, change data retriever, callback, and statistics parameters. (Inherited from RelationalSyncProvider.)
Public methodToString (Inherited from Object.)
Top

  NameDescription
Public eventApplyChangeFailedOccurs during uploading, after failing to apply a row at a node. (Inherited from RelationalSyncProvider.)
Public eventApplyingChangesOccurs during uploading, after connecting to the database but before applying changes. (Inherited from RelationalSyncProvider.)
Public eventApplyMetadataFailedOccurs during uploading, after failing to apply metadata for a row. (Inherited from RelationalSyncProvider.)
Public eventBatchAppliedOccurs after each batch of changes has been applied to the destination. (Inherited from RelationalSyncProvider.)
Public eventBatchSpooledOccurs after each batch of changes has been written to disk. (Inherited from RelationalSyncProvider.)
Public eventBeginSnapshotInitializationOccurs when Sync Framework determines that a database is a snapshot that needs to be initialized before synchronization starts.
Public eventChangesAppliedOccurs during uploading, after applying changes but before disconnecting from the database. (Inherited from RelationalSyncProvider.)
Public eventChangesSelectedOccurs during downloading, after enumerating changes but before disconnecting from the database. (Inherited from RelationalSyncProvider.)
Public eventDbConnectionFailureOccurs when the database connection fails during change application. (Inherited from RelationalSyncProvider.)
Public eventEndSnapshotInitializationOccurs when all tables for a particular scope have been initialized from a snapshot.
Public eventSelectingChangesOccurs during downloading, after connecting to the database but before selecting changes. (Inherited from RelationalSyncProvider.)
Public eventSyncPeerOutdatedOccurs before enumeration of changes if the destination node is outdated. (Inherited from RelationalSyncProvider.)
Public eventSyncProgressOccurs during the selection of changes (per table) and the application of changes (per row). (Inherited from RelationalSyncProvider.)
Top

The principal activities of a synchronization provider are as follows:

  • Stores information about tables on the peer that are enabled for synchronization.

  • Enables applications to retrieve changes that occurred in the database since the last synchronization.

  • Applies incremental changes to the database.

  • Detects conflicting changes.

The following code example instantiates providers for three different synchronization sessions: between a server and a SQL Server client; between the server and the SQL Server client; between the SQL Server client and one of the SQL Server Compact clients; and between the server and the other SQL Server Compact client. One of the SQL Server Compact clients is initialized by using a database snapshot. To view this code in the context of a complete example, see How To: Execute Database Synchronization (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")


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft