SqlSyncAdapterBuilder Class

Creates a SyncAdapter and the SQL commands that are required to synchronize a client with a SQL Server database.

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      Microsoft.Synchronization.Data.Server.SqlSyncAdapterBuilder

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

Syntax

'Declaration
Public Class SqlSyncAdapterBuilder _
    Inherits Component
'Usage
Dim instance As SqlSyncAdapterBuilder
public class SqlSyncAdapterBuilder : Component
public ref class SqlSyncAdapterBuilder : public Component
type SqlSyncAdapterBuilder =  
    class
        inherit Component
    end
public class SqlSyncAdapterBuilder extends Component

The SqlSyncAdapterBuilder type exposes the following members.

Constructors

  Name Description
Public method SqlSyncAdapterBuilder() Initializes a new instance of the SqlSyncAdapterBuilder class by using default values.
Public method SqlSyncAdapterBuilder(SqlConnection) Initializes a new instance of the SqlSyncAdapterBuilder class by using a connection parameter.

Top

Properties

  Name Description
Protected property CanRaiseEvents (Inherited from Component.)
Public property ChangeTrackingType Specifies whether the server database uses the change tracking feature in SQL Server or a custom coupled change tracking system, with a default of CoupledChangeTracking.
Public property Connection Gets or sets the connection to the server database.
Public property Container (Inherited from Component.)
Public property CreationOriginatorIdColumn Gets or sets the column in the base table that is used to track who inserts a row.
Public property CreationTrackingColumn Gets or sets the column in the base table that is used to track when a row is inserted.
Public property DataColumns Gets a collection of data columns to be synchronized. This enables you to synchronize a subset of the columns in the table.
Public property DeletionOriginatorIdColumn Gets or sets the column in the tombstone table that is used to track who deletes a row.
Public property DeletionTrackingColumn Gets or sets the column in the tombstone table that is used to track when a row is deleted.
Protected property DesignMode (Inherited from Component.)
Protected property Events (Inherited from Component.)
Public property FilterClause Specifies the SQL WHERE clause (without the WHERE keyword) that is used to filter the result set from the base table.
Public property FilterParameters Gets a collection of filter parameters that are used in the FilterClause.
Public property QuotePrefix Specifies the left delimiter (such as a left square bracket) that is used for database object names, such as tables and columns.
Public property QuoteSuffix Specifies the right delimiter (such as a right square bracket) that is used for database object names, such as tables and columns.
Public property RowGuidColumn Gets or sets a column of uniqueidentifier data type that is used to identify rows in the base table and the tombstone table.
Public property Site (Inherited from Component.)
Public property SyncDirection Specifies the direction of synchronization from the perspective of the client, with a default direction of Bidirectional.
Public property TableName Gets or sets the name of the base table for which to create a SyncAdapter object.
Public property TombstoneDataColumns Gets a collection of data columns to be synchronized. This enables you to synchronize a subset of the columns in the table.
Public property TombstoneFilterClause Specifies the SQL WHERE clause (without the WHERE keyword) that is used to filter the result set from the tombstone table.
Public property TombstoneFilterParameters Gets a collection of filter parameters that are used in the TombstoneFilterClause.
Public property TombstoneTableName Gets or sets the name of the tombstone table that is used to synchronize deletes.
Public property UpdateOriginatorIdColumn Gets or sets the column in the base table that is used to track who updates a row.
Public property UpdateTrackingColumn Gets or sets the column in the base table that is used to track when a row is updated.

Top

Methods

  Name Description
Public method CreateObjRef (Inherited from MarshalByRefObject.)
Public method Dispose() (Inherited from Component.)
Protected method Dispose(Boolean) (Inherited from Component.)
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Component.)
Public method GetHashCode (Inherited from Object.)
Public method GetLifetimeService (Inherited from MarshalByRefObject.)
Protected method GetService (Inherited from Component.)
Public method GetType (Inherited from Object.)
Public method InitializeLifetimeService (Inherited from MarshalByRefObject.)
Protected method MemberwiseClone() (Inherited from Object.)
Protected method MemberwiseClone(Boolean) (Inherited from MarshalByRefObject.)
Public method ToString (Inherited from Component.)
Public method ToSyncAdapter() Creates a synchronization adapter for the table specified in TableName.
Public method ToSyncAdapter(Boolean, Boolean, Boolean, Boolean) Creates a synchronization adapter for the table specified in TableName, with the option of not downloading tracking columns to the client.

Top

Events

  Name Description
Public event Disposed (Inherited from Component.)

Top

Remarks

The synchronization adapter builder is modeled after the command builder in ADO.NET. You can use this tool to develop code for the synchronization commands that are executed by the server synchronization provider. The synchronization adapter builder produces SELECT, INSERT, UPDATE, and DELETE statements for SQL Server databases based on information that you provide about the tables that are involved in synchronization. The synchronization adapter builder enables you to specify the following information:

  • The tables that you want to synchronize

  • The tracking columns in those tables

  • The direction of synchronization

  • Which rows and columns to include

The synchronization adapter builder uses this information to create a synchronization adapter and Transact-SQL commands. The synchronization adapter builder is compatible with SQL Server 2000 and later versions.

Note

You can use the synchronization adapter builder to become familiar with synchronization commands. However, if you can, we recommend that you manually specify commands that use stored procedures. Stored procedures can help improve the performance and security of the application.

Examples

The following code example creates a SyncAdapter object for the Customer table by using the SqlSyncAdapterBuilder. Columns in the table are specified for several properties, and synchronization is specified as bidirectional. To view this code in the context of a complete example, see How to: Work with Events and Program Business Logic.

SqlSyncAdapterBuilder customerBuilder = new SqlSyncAdapterBuilder(serverConn);

customerBuilder.TableName = "Sales.Customer";
customerBuilder.TombstoneTableName = customerBuilder.TableName + "_Tombstone";
customerBuilder.SyncDirection = SyncDirection.Bidirectional;
customerBuilder.CreationTrackingColumn = "InsertTimestamp";
customerBuilder.UpdateTrackingColumn = "UpdateTimestamp";
customerBuilder.DeletionTrackingColumn = "DeleteTimestamp";
customerBuilder.CreationOriginatorIdColumn = "InsertId";
customerBuilder.UpdateOriginatorIdColumn = "UpdateId";
customerBuilder.DeletionOriginatorIdColumn = "DeleteId";

SyncAdapter customerSyncAdapter = customerBuilder.ToSyncAdapter();
customerSyncAdapter.TableName = "Customer";
this.SyncAdapters.Add(customerSyncAdapter);
Dim customerBuilder As New SqlSyncAdapterBuilder(serverConn)
With customerBuilder
    .TableName = "Sales.Customer"
    .TombstoneTableName = customerBuilder.TableName + "_Tombstone"
    .SyncDirection = SyncDirection.Bidirectional
    .CreationTrackingColumn = "InsertTimestamp"
    .UpdateTrackingColumn = "UpdateTimestamp"
    .DeletionTrackingColumn = "DeleteTimestamp"
    .CreationOriginatorIdColumn = "InsertId"
    .UpdateOriginatorIdColumn = "UpdateId"
    .DeletionOriginatorIdColumn = "DeleteId"
End With

Dim customerSyncAdapter As SyncAdapter = customerBuilder.ToSyncAdapter()
customerSyncAdapter.TableName = "Customer"
Me.SyncAdapters.Add(customerSyncAdapter)

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.

See Also

Reference

Microsoft.Synchronization.Data.Server Namespace