DbSyncProvider.SelectNewTimestampCommand 属性

获取或设置一个 IDbCommand 对象,该对象包含从对等数据库返回新时间戳值的查询或存储过程。时间戳定义要在当前会话期间同步的变更集的上限。

此属性不符合 CLS。  

命名空间: Microsoft.Synchronization.Data
程序集: Microsoft.Synchronization.Data(在 microsoft.synchronization.data.dll 中)

语法

声明
Public Property SelectNewTimestampCommand As IDbCommand
用法
Dim instance As DbSyncProvider
Dim value As IDbCommand

value = instance.SelectNewTimestampCommand

instance.SelectNewTimestampCommand = value
public IDbCommand SelectNewTimestampCommand { get; set; }
public:
property IDbCommand^ SelectNewTimestampCommand {
    IDbCommand^ get ();
    void set (IDbCommand^ value);
}
/** @property */
public IDbCommand get_SelectNewTimestampCommand ()

/** @property */
public void set_SelectNewTimestampCommand (IDbCommand value)
public function get SelectNewTimestampCommand () : IDbCommand

public function set SelectNewTimestampCommand (value : IDbCommand)

属性值

包含查询或存储过程的 IDbCommand 对象。

备注

为此命令指定的查询或存储过程返回 timestamp 值,该值用于选择变更集并将其应用于每个对等方。在当前同步会话期间,该命令会提供一个新的 timestamp 值。将对上次同步会话期间的 timestamp 值之后和新的 timestamp 值之前所做的变更进行同步。然后,新值将存储起来并用作下一个会话的起始点。

示例

以下代码示例指定一条从对等方检索新 timestamp 值的命令。在此情况下,MIN_ACTIVE_ROWVERSION 从 SQL Server 数据库返回一个 timestamp 值。(MIN_ACTIVE_ROWVERSION 是在 SQL Server 2005 Service Pack 2 中引入的。)之所以使用 timestamp 值,原因是对等数据库中的跟踪列包含 timestamp 值。若要在完整示例上下文中查看此代码,请参见如何配置变更跟踪和同步对等方

SqlCommand selectNewTimestampCommand = new SqlCommand();
string newTimestampVariable = "@" + DbSyncSession.SyncNewTimestamp;
selectNewTimestampCommand.CommandText = "SELECT " + newTimestampVariable + " = min_active_rowversion() - 1";
selectNewTimestampCommand.Parameters.Add(newTimestampVariable, SqlDbType.Timestamp);
selectNewTimestampCommand.Parameters[newTimestampVariable].Direction = ParameterDirection.Output;

peerProvider.SelectNewTimestampCommand = selectNewTimestampCommand;
Dim newTimestampVariable As String = "@" + DbSyncSession.SyncNewTimestamp

Dim selectNewTimestampCommand As New SqlCommand()

With selectNewTimestampCommand
    .CommandText = "SELECT " + newTimestampVariable + " = min_active_rowversion() - 1"
    .Parameters.Add(newTimestampVariable, SqlDbType.Timestamp)
    .Parameters(newTimestampVariable).Direction = ParameterDirection.Output
End With

peerProvider.SelectNewTimestampCommand = selectNewTimestampCommand

请参阅

参考

DbSyncProvider 类
DbSyncProvider 成员
Microsoft.Synchronization.Data 命名空间