SyncAdapter.SelectIncrementalDeletesCommand 属性

获取或设置查询或存储过程,用于检索自上次同步之后在服务器数据库中进行的删除。

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

语法

声明
Public Property SelectIncrementalDeletesCommand As IDbCommand
用法
Dim instance As SyncAdapter
Dim value As IDbCommand

value = instance.SelectIncrementalDeletesCommand

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

/** @property */
public void set_SelectIncrementalDeletesCommand (IDbCommand value)
public function get SelectIncrementalDeletesCommand () : IDbCommand

public function set SelectIncrementalDeletesCommand (value : IDbCommand)

属性值

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

备注

使用同步适配器命令可以指定用于从服务器数据库中选择变更和向服务器数据库应用变更的查询和存储过程。有关更多信息,请参见如何指定快照同步、下载同步、上载同步和双向同步。每个命令都使用会话变量,通过这些变量可以在同步期间传递值。这些变量的指定方式与 ADO.NET 命令中查询或存储过程的其他参数相似。有关更多信息,请参见如何使用会话变量

示例

下面的代码示例创建一个命令,该命令可在双向和仅下载同步方案中从 Customer_Tombstone 表中选择已删除的行。若要在完整示例上下文中查看此代码,请参见如何处理数据冲突和错误

SqlCommand customerIncrDeletes = new SqlCommand();
customerIncrDeletes.CommandText =
    "SELECT CustomerId, CustomerName, SalesPerson, CustomerType " +
    "FROM Sales.Customer_Tombstone " +
    "WHERE (@sync_initialized = 1 " +
    "AND DeleteTimestamp > @sync_last_received_anchor " +
    "AND DeleteTimestamp <= @sync_new_received_anchor " +
    "AND DeleteId <> @sync_client_id)";
customerIncrDeletes.Parameters.Add("@" + SyncSession.SyncInitialized, SqlDbType.Bit);
customerIncrDeletes.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp);
customerIncrDeletes.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp);
customerIncrDeletes.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
customerIncrDeletes.Connection = serverConn;
customerSyncAdapter.SelectIncrementalDeletesCommand = customerIncrDeletes;
Dim customerIncrDeletes As New SqlCommand()
With customerIncrDeletes
    .CommandText = _
        "SELECT CustomerId, CustomerName, SalesPerson, CustomerType " _
      & "FROM Sales.Customer_Tombstone " _
      & "WHERE (@sync_initialized = 1 " _
      & "AND DeleteTimestamp > @sync_last_received_anchor " _
      & "AND DeleteTimestamp <= @sync_new_received_anchor " _
      & "AND DeleteId <> @sync_client_id)"
    .Parameters.Add("@" + SyncSession.SyncInitialized, SqlDbType.Bit)
    .Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp)
    .Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp)
    .Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier)
    .Connection = serverConn
End With
customerSyncAdapter.SelectIncrementalDeletesCommand = customerIncrDeletes

请参阅

参考

SyncAdapter 类
SyncAdapter 成员
Microsoft.Synchronization.Data.Server 命名空间