Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)
/** @property */ public IDbCommand get_SelectNewAnchorCommand () /** @property */ public void set_SelectNewAnchorCommand (IDbCommand value)
public function get SelectNewAnchorCommand () : IDbCommand public function set SelectNewAnchorCommand (value : IDbCommand)
Property ValueAn IDbCommand object that contains a query or stored procedure.
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: A Synchronization Services Application.
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;