DbServerSyncProvider.BatchSize 属性

获取或设置由从服务器数据库检索变更的命令使用的批大小(以行为单位)。

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

语法

声明
Public Property BatchSize As Integer
用法
Dim instance As DbServerSyncProvider
Dim value As Integer

value = instance.BatchSize

instance.BatchSize = value
public int BatchSize { get; set; }
public:
property int BatchSize {
    int get ();
    void set (int value);
}
/** @property */
public int get_BatchSize ()

/** @property */
public void set_BatchSize (int value)
public function get BatchSize () : int

public function set BatchSize (value : int)

属性值

由从服务器数据库检索变更的命令使用的批大小(以行为单位)。

备注

Sync Framework 使应用程序能够下载对客户端进行的批量变更(上载不支持批处理)。通过为 BatchSize 属性指定一个值,并为 SelectNewAnchorCommand 属性创建一个可返回每批变更的定位点值的命令,可以启用批处理。有关更多信息,请参见如何指定变更的顺序和批大小

示例

下面的代码示例创建一个定位点命令,如果分批发送变更,则可以使用该命令。该命令为每批变更返回一个新定位点值,而不是为整个变更集返回一个新定位点值。示例使用 BatchSize 属性指定每批中的变更数,并指定用于在存储过程和同步运行时之间来回传递定位点值的会话变量。手动编写同步适配器命令时,仍可以使用 @sync_new_received_anchor@sync_last_received_anchor 会话变量。@sync_max_received_anchor 会话变量仅由新定位点命令使用。若要在完整示例上下文中查看此代码,请参见如何指定变更的顺序和批大小

SqlCommand selectNewAnchorCommand = new SqlCommand();
selectNewAnchorCommand.Connection = serverConn;
selectNewAnchorCommand.CommandText = "usp_GetNewBatchAnchor";
selectNewAnchorCommand.CommandType = CommandType.StoredProcedure;            
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp, 8);
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncMaxReceivedAnchor, SqlDbType.Timestamp, 8);
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp, 8);
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncBatchSize, SqlDbType.Int, 4);
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncBatchCount, SqlDbType.Int, 4);            

selectNewAnchorCommand.Parameters["@" + SyncSession.SyncMaxReceivedAnchor].Direction = ParameterDirection.Output;
selectNewAnchorCommand.Parameters["@" + SyncSession.SyncNewReceivedAnchor].Direction = ParameterDirection.Output;
selectNewAnchorCommand.Parameters["@" + SyncSession.SyncBatchCount].Direction = ParameterDirection.InputOutput;
this.SelectNewAnchorCommand = selectNewAnchorCommand;
this.BatchSize = 50;
Dim selectNewAnchorCommand As New SqlCommand()
selectNewAnchorCommand.Connection = serverConn
selectNewAnchorCommand.CommandText = "usp_GetNewBatchAnchor"
selectNewAnchorCommand.CommandType = CommandType.StoredProcedure
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp, 8)
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncMaxReceivedAnchor, SqlDbType.Timestamp, 8)
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp, 8)
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncBatchSize, SqlDbType.Int, 4)
selectNewAnchorCommand.Parameters.Add("@" + SyncSession.SyncBatchCount, SqlDbType.Int, 4)

selectNewAnchorCommand.Parameters("@" + SyncSession.SyncMaxReceivedAnchor).Direction = ParameterDirection.Output
selectNewAnchorCommand.Parameters("@" + SyncSession.SyncNewReceivedAnchor).Direction = ParameterDirection.Output
selectNewAnchorCommand.Parameters("@" + SyncSession.SyncBatchCount).Direction = ParameterDirection.InputOutput
Me.SelectNewAnchorCommand = selectNewAnchorCommand
Me.BatchSize = 50

请参阅

参考

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