SqlSyncProvider Class
Represents a synchronization provider that communicates with a SQL Server database and shields other Sync Framework components from the specific implementation of the database.
This API is not CLS-compliant.
Inheritance Hierarchy
System.Object
Microsoft.Synchronization.SyncProvider
Microsoft.Synchronization.KnowledgeSyncProvider
Microsoft.Synchronization.Data.RelationalSyncProvider
Microsoft.Synchronization.Data.SqlServer.SqlSyncProvider
Namespace: Microsoft.Synchronization.Data.SqlServer
Assembly: Microsoft.Synchronization.Data.SqlServer (in Microsoft.Synchronization.Data.SqlServer.dll)
Syntax
'Declaration
<CLSCompliantAttribute(False)> _
Public Class SqlSyncProvider _
Inherits RelationalSyncProvider
'Usage
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
The SqlSyncProvider type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() |
SqlSyncProvider() | Initializes a new instance of the SqlSyncProvider class by using default values. |
![]() |
SqlSyncProvider(String, SqlConnection) | Initializes a new instance of the SqlSyncProvider class for the specified scope name and connection. |
![]() |
SqlSyncProvider(String, SqlConnection, String) | Initializes a new instance of the SqlSyncProvider class for the specified scope name, connection, and synchronization object prefix. |
![]() |
SqlSyncProvider(String, SqlConnection, String, String) | Initializes a new instance of the SqlSyncProvider class for the specified scope name, connection, synchronization object prefix, and object schema. |
Top
Properties
Name | Description | |
---|---|---|
![]() |
ApplicationTransactionSize | Gets or sets the maximum transaction size used during change application, in kilobytes. |
![]() |
BatchingDirectory | Gets or sets the directory in which batch files are spooled to disk. (Inherited from RelationalSyncProvider.) |
![]() |
CleanupBatchingDirectory | Gets or sets whether to clean up batching files after the changes in the files have been applied to the destination. (Inherited from RelationalSyncProvider.) |
![]() |
CommandTimeout | Gets or sets the wait time, in seconds, before a synchronization command is stopped and an error is generated. |
![]() |
Configuration | Not implemented by RelationalSyncProvider. An exception of type NotSupportedException is thrown if you attempt to access this property. (Inherited from RelationalSyncProvider.) |
![]() |
Connection | Gets or sets an IDbConnection object that is used to connect to the database. (Inherited from RelationalSyncProvider.) |
![]() |
DestinationCallbacks | Gets an object that a synchronization application can use to register to receive notification of events that occur during synchronization. (Inherited from KnowledgeSyncProvider.) |
![]() |
IdFormats | Gets a SyncIdFormatGroup object that is used to identify entities in a synchronization session. (Inherited from RelationalSyncProvider.) |
![]() |
MemoryDataCacheSize | Gets 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.) |
![]() |
ObjectPrefix | Gets or sets the optional prefix that is used to identify objects that Sync Framework creates. |
![]() |
ObjectSchema | Gets or sets the optional database schema in which Sync Framework creates objects. |
![]() |
ScopeName | Sets the name of the scope to synchronize, which is a logical group of tables with optional filters. (Overrides RelationalSyncProvider.ScopeName.) |
![]() |
SyncProviderPosition | Gets or sets a SyncProviderPosition enumeration value that represents whether a provider is associated with the local or remote database. (Inherited from RelationalSyncProvider.) |
Top
Methods
Name | Description | |
---|---|---|
![]() |
BeginSession | Called by the SyncOrchestrator to indicate that a synchronization session has started. (Overrides RelationalSyncProvider.BeginSession(SyncProviderPosition, SyncSessionContext).) |
![]() |
CreateApplicationTransaction | Creates a read-committed transaction over which to apply changes to the database. (Inherited from RelationalSyncProvider.) |
![]() |
CreateEnumerationTransaction | Creates a read-committed transaction over which to enumerate changes from the database. (Inherited from RelationalSyncProvider.) |
![]() |
Dispose() | Releases all resources that are used by the RelationalSyncProvider. (Inherited from RelationalSyncProvider.) |
![]() |
Dispose(Boolean) | Releases the unmanaged resources used by the RelationalSyncProvider and optionally releases the managed resources. (Inherited from RelationalSyncProvider.) |
![]() |
EndSession | Called by the SyncOrchestrator object to indicate that a synchronization session has ended. (Inherited from RelationalSyncProvider.) |
![]() |
Equals | (Inherited from Object.) |
![]() |
Finalize | (Inherited from Object.) |
![]() |
GetChangeBatch | Gets a batch of changes to synchronize when given batch size, destination knowledge, and change data retriever parameters. (Inherited from RelationalSyncProvider.) |
![]() |
GetFullEnumerationChangeBatch | Gets a batch of changes to synchronize when given batch size, lower bound, knowledge, and change data retriever parameters. (Inherited from RelationalSyncProvider.) |
![]() |
GetHashCode | (Inherited from Object.) |
![]() |
GetSyncBatchParameters | Gets the number of kilobytes of data that will be included in change batches, and the current knowledge for the synchronization scope. (Inherited from RelationalSyncProvider.) |
![]() |
GetType | (Inherited from Object.) |
![]() |
MemberwiseClone | (Inherited from Object.) |
![]() |
OnApplyChangeFailed | Raises the ApplyMetadataFailed event. (Inherited from RelationalSyncProvider.) |
![]() |
OnApplyingChanges | Raises the ApplyingChanges event. (Inherited from RelationalSyncProvider.) |
![]() |
OnApplyMetadataFailed | Raises the ApplyMetadataFailed event. (Inherited from RelationalSyncProvider.) |
![]() |
OnChangesApplied | Raises the ChangesApplied event. (Inherited from RelationalSyncProvider.) |
![]() |
OnChangesSelected | Raises the ChangesSelected event. (Inherited from RelationalSyncProvider.) |
![]() |
OnDbConnectionFailure | Raises the DbConnectionFailure event. (Inherited from RelationalSyncProvider.) |
![]() |
OnPeerOutdated | Raises the SyncPeerOutdated event. (Inherited from RelationalSyncProvider.) |
![]() |
OnSelectingChanges | Raises the SelectingChanges event. (Inherited from RelationalSyncProvider.) |
![]() |
OnSyncProgress | Raises the SyncProgress event. (Inherited from RelationalSyncProvider.) |
![]() |
ProcessChangeBatch | Processes a batch of changes when given resolution policy, source changes, change data retriever, callback, and statistics parameters. (Inherited from RelationalSyncProvider.) |
![]() |
ProcessFullEnumerationChangeBatch | Processes a batch of changes when given resolution policy, source changes, change data retriever, callback, and statistics parameters. (Inherited from RelationalSyncProvider.) |
![]() |
ToString | (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
![]() |
ApplyChangeFailed | Occurs during uploading, after failing to apply a row at a node. (Inherited from RelationalSyncProvider.) |
![]() |
ApplyingChanges | Occurs during uploading, after connecting to the database but before applying changes. (Inherited from RelationalSyncProvider.) |
![]() |
ApplyMetadataFailed | Occurs during uploading, after failing to apply metadata for a row. (Inherited from RelationalSyncProvider.) |
![]() |
BatchApplied | Occurs after each batch of changes has been applied to the destination. (Inherited from RelationalSyncProvider.) |
![]() |
BatchSpooled | Occurs after each batch of changes has been written to disk. (Inherited from RelationalSyncProvider.) |
![]() |
ChangesApplied | Occurs during uploading, after applying changes but before disconnecting from the database. (Inherited from RelationalSyncProvider.) |
![]() |
ChangesSelected | Occurs during downloading, after enumerating changes but before disconnecting from the database. (Inherited from RelationalSyncProvider.) |
![]() |
DbConnectionFailure | Occurs when the database connection fails during change application. (Inherited from RelationalSyncProvider.) |
![]() |
SelectingChanges | Occurs during downloading, after connecting to the database but before selecting changes. (Inherited from RelationalSyncProvider.) |
![]() |
SyncPeerOutdated | Occurs before enumeration of changes if the destination node is outdated. (Inherited from RelationalSyncProvider.) |
![]() |
SyncProgress | Occurs during the selection of changes (per table) and the application of changes (per row). (Inherited from RelationalSyncProvider.) |
Top
Remarks
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.
Examples
The following code example instantiates providers for three different synchronization sessions: 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")
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.