DbSyncProvider.SelectTableMaxTimestampsCommand Property

Gets or sets an IDbCommand object that contains the query or stored procedure that selects the maximum timestamp from each base table or tracking table, to determine whether for each table the destination already has all of the changes from the source.

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

public virtual IDbCommand SelectTableMaxTimestampsCommand { get; set; }

Property Value

Type: System.Data.IDbCommand
An IDbCommand object that contains a query or stored procedure.

The following code example creates a command for the SelectTableMaxTimestampsCommand property. In the complete code example in How to: Provision a Server Database for Collaborative Synchronization (Non-SQL Server), there are synchronization sessions in which no new changes have been made at either node. In these sessions, the call to the command that is specified for the SelectTableMaxTimestampsCommand property indicates that no data changes are available to synchronize. Therefore, the command that is specified for the SelectIncrementalChangesCommand property is not called.

SqlCommand selTableMaxTsCmd = new SqlCommand();
selTableMaxTsCmd.CommandType = CommandType.Text;
selTableMaxTsCmd.CommandText = "SELECT 'Customer' AS table_name, " +
                               "MAX(local_update_peer_timestamp) AS max_timestamp " +
                               "FROM Sync.Customer_Tracking";
sampleDbProvider.SelectTableMaxTimestampsCommand = selTableMaxTsCmd;


Dim selTableMaxTsCmd As New SqlCommand()
selTableMaxTsCmd.CommandType = CommandType.Text
selTableMaxTsCmd.CommandText = "SELECT 'Customer' AS table_name, " _
                             & "MAX(local_update_peer_timestamp) AS max_timestamp " _
                             & "FROM Sync.Customer_Tracking"
sampleDbProvider.SelectTableMaxTimestampsCommand = selTableMaxTsCmd


Dim selTableMaxTsCmd As New SqlCommand()
selTableMaxTsCmd.CommandType = CommandType.Text
selTableMaxTsCmd.CommandText = "SELECT 'Customer' AS table_name, " _
                             & "MAX(local_update_peer_timestamp) AS max_timestamp " _
                             & "FROM Sync.Customer_Tracking"
sampleDbProvider.SelectTableMaxTimestampsCommand = selTableMaxTsCmd


Show: