DbSyncProvider.SelectScopeInfoCommand 属性

获取或设置一个 IDbCommand 对象,该对象包含从对等数据库返回作用域元数据的查询或存储过程。

此属性不符合 CLS。  

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

语法

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

value = instance.SelectScopeInfoCommand

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

/** @property */
public void set_SelectScopeInfoCommand (IDbCommand value)
public function get SelectScopeInfoCommand () : IDbCommand

public function set SelectScopeInfoCommand (value : IDbCommand)

属性值

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

备注

此命令返回来自作用域元数据表的信息,例如 Sync Services 所需的同步知识和清除知识。有关如何使用作用域的更多信息,请参见如何配置变更跟踪和同步对等方中的“创建用于存储元数据的跟踪表”。

示例

以下代码示例指定一条从每个对等数据库的作用域表中选择元数据的命令。若要在完整示例上下文中查看此代码,请参见如何配置变更跟踪和同步对等方

SqlCommand selReplicaInfoCmd = new SqlCommand();
selReplicaInfoCmd.CommandType = CommandType.Text;
selReplicaInfoCmd.CommandText = "SELECT " +
                                "@" + DbSyncSession.SyncScopeId + " = scope_id, " +
                                "@" + DbSyncSession.SyncScopeKnowledge + " = scope_sync_knowledge, " +
                                "@" + DbSyncSession.SyncScopeCleanupKnowledge + " = scope_tombstone_cleanup_knowledge, " +
                                "@" + DbSyncSession.SyncScopeTimestamp + " = scope_timestamp " +
                                "FROM Sales.ScopeInfo " +
                                "WHERE scope_name = @" + DbSyncSession.SyncScopeName;
selReplicaInfoCmd.Parameters.Add("@" + DbSyncSession.SyncScopeName, SqlDbType.NVarChar, 100);
selReplicaInfoCmd.Parameters.Add("@" + DbSyncSession.SyncScopeId, SqlDbType.UniqueIdentifier).Direction = ParameterDirection.Output;
selReplicaInfoCmd.Parameters.Add("@" + DbSyncSession.SyncScopeKnowledge, SqlDbType.VarBinary, 10000).Direction = ParameterDirection.Output;
selReplicaInfoCmd.Parameters.Add("@" + DbSyncSession.SyncScopeCleanupKnowledge, SqlDbType.VarBinary, 10000).Direction = ParameterDirection.Output;
selReplicaInfoCmd.Parameters.Add("@" + DbSyncSession.SyncScopeTimestamp, SqlDbType.BigInt).Direction = ParameterDirection.Output;

peerProvider.SelectScopeInfoCommand = selReplicaInfoCmd;
Dim selReplicaInfoCmd As New SqlCommand()

With selReplicaInfoCmd
    .CommandType = CommandType.Text
    .CommandText = "SELECT " _
                 & "@" + DbSyncSession.SyncScopeId + " = scope_id, " _
                 & "@" + DbSyncSession.SyncScopeKnowledge + " = scope_sync_knowledge, " _
                 & "@" + DbSyncSession.SyncScopeCleanupKnowledge + " = scope_tombstone_cleanup_knowledge, " _
                 & "@" + DbSyncSession.SyncScopeTimestamp + " = scope_timestamp " _
                 & "FROM Sales.ScopeInfo " _
                 & "WHERE scope_name = @" + DbSyncSession.SyncScopeName
    .Parameters.Add("@" + DbSyncSession.SyncScopeName, SqlDbType.NVarChar, 100)
    .Parameters.Add("@" + DbSyncSession.SyncScopeId, SqlDbType.UniqueIdentifier).Direction = ParameterDirection.Output
    .Parameters.Add("@" + DbSyncSession.SyncScopeKnowledge, SqlDbType.VarBinary, 10000).Direction = ParameterDirection.Output
    .Parameters.Add("@" + DbSyncSession.SyncScopeCleanupKnowledge, SqlDbType.VarBinary, 10000).Direction = ParameterDirection.Output
    .Parameters.Add("@" + DbSyncSession.SyncScopeTimestamp, SqlDbType.BigInt).Direction = ParameterDirection.Output
End With

peerProvider.SelectScopeInfoCommand = selReplicaInfoCmd

请参阅

参考

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