DbSyncAdapter.InsertMetadataCommand 属性

获取或设置用于向元数据表插入元数据的查询或存储过程。

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

语法

声明
Public Property InsertMetadataCommand As IDbCommand
用法
Dim instance As DbSyncAdapter
Dim value As IDbCommand

value = instance.InsertMetadataCommand

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

/** @property */
public void set_InsertMetadataCommand (IDbCommand value)
public function get InsertMetadataCommand () : IDbCommand

public function set InsertMetadataCommand (value : IDbCommand)

属性值

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

备注

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

示例

下面的代码示例创建一个命令,该命令向对等方的 Customer_Tracking 表中插入行。该命令是一个在 用于 Sync Services 帮助主题的安装脚本中定义的存储过程。若要在完整示例上下文中查看此代码,请参见如何配置变更跟踪和同步对等方

SqlCommand insMetadataCustomerCmd = new SqlCommand();
insMetadataCustomerCmd.CommandType = CommandType.StoredProcedure;
insMetadataCustomerCmd.CommandText = "Sales.sp_Customer_InsertMetadata";
insMetadataCustomerCmd.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncCreatePeerKey, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncCreatePeerTimestamp, SqlDbType.BigInt);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncUpdatePeerKey, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncUpdatePeerTimestamp, SqlDbType.BigInt);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowIsTombstone, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;

adapterCustomer.InsertMetadataCommand = insMetadataCustomerCmd;
Dim insMetadataCustomerCmd As New SqlCommand()

With insMetadataCustomerCmd
    .CommandType = CommandType.StoredProcedure
    .CommandText = "Sales.sp_Customer_InsertMetadata"
    .Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier)
    .Parameters.Add("@" + DbSyncSession.SyncCreatePeerKey, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncCreatePeerTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncUpdatePeerKey, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncUpdatePeerTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncRowIsTombstone, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output
End With

adapterCustomer.InsertMetadataCommand = insMetadataCustomerCmd

请参阅

参考

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