Gets or sets an IDbCommand object that contains the query or stored procedure that returns a new anchor value from the server database. The anchor defines the upper bound for the set of changes to be synchronized during the current session.
Assembly: Microsoft.Synchronization.Data.Server (in Microsoft.Synchronization.Data.Server.dll)
During the current synchronization, the new anchor command provides a new anchor value. Changes that are made after the last received anchor value and before the new received anchor value are synchronized. The new received anchor is then stored and used as the last received anchor value for the next synchronization. For more information, see the section "Determining Which Data Changes to Download to a Client" in Tracking Changes in the Server Database.
The following code example specifies a command to retrieve a new anchor value from the server. In this case, MIN_ACTIVE_ROWVERSION returns a timestamp value from a SQL Server database. (MIN_ACTIVE_ROWVERSION was introduced in SQL Server 2005 Service Pack 2.) A timestamp value is used because the tracking columns in the server database contain timestamp values. If the tracking columns contained date values, you could use a function such as GETUTCDATE() instead of MIN_ACTIVE_ROWVERSION. SyncSession contains several string constants that can be used in synchronization commands. SyncNewReceivedAnchor is one of these constants. You could also use the literal @sync_new_received_anchor directly in your queries. To view this code in the context of a complete example, see Getting Started: Client and Server Synchronization.
SqlCommand selectNewAnchorCommand = new SqlCommand(); string newAnchorVariable = "@" + SyncSession.SyncNewReceivedAnchor; selectNewAnchorCommand.CommandText = "SELECT " + newAnchorVariable + " = min_active_rowversion() - 1"; selectNewAnchorCommand.Parameters.Add(newAnchorVariable, SqlDbType.Timestamp); selectNewAnchorCommand.Parameters[newAnchorVariable].Direction = ParameterDirection.Output; selectNewAnchorCommand.Connection = serverConn; this.SelectNewAnchorCommand = selectNewAnchorCommand;
Dim selectNewAnchorCommand As New SqlCommand() Dim newAnchorVariable As String = "@" + SyncSession.SyncNewReceivedAnchor selectNewAnchorCommand.CommandText = "SELECT " + newAnchorVariable + " = min_active_rowversion() - 1" selectNewAnchorCommand.Parameters.Add(newAnchorVariable, SqlDbType.Timestamp) selectNewAnchorCommand.Parameters(newAnchorVariable).Direction = ParameterDirection.Output selectNewAnchorCommand.Connection = serverConn Me.SelectNewAnchorCommand = selectNewAnchorCommand