BatchSize 屬性
取得或設定從伺服器資料庫擷取變更之命令所使用的批次大小 (以資料列為單位)。
命名空間: Microsoft.Synchronization.Data.Server
組件: Microsoft.Synchronization.Data.Server (在 Microsoft.Synchronization.Data.Server.dll 中)
語法
'宣告
Public Property BatchSize As Integer
Get
Set
'用途
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);
}
member BatchSize : int with get, set
function get BatchSize () : int
function set BatchSize (value : int)
屬性值
型別:System. . :: . .Int32
從伺服器資料庫擷取變更之命令所使用的批次大小 (以資料列為單位)。
備註
Sync Framework 可讓應用程式將變更的批次下載至用戶端 (上傳時不支援批次處理)。批次處理的啟用方式是針對 BatchSize 屬性指定一個值,然後為 SelectNewAnchorCommand 屬性建立一個命令,以便傳回每個變更批次的錨定值。如需詳細資訊,請參閱 HOW TO:指定變更的順序和批次大小。
範例
下列程式碼範例會建立可在變更按批次傳送時使用的錨定命令。它會針對每個變更批次傳回新的錨定值,而非針對完整變更集合,傳回新的錨定值一次。此範例會使用 BatchSize 屬性來指定每個批次應該有多少個變更,以及要在預存程序與同步處理執行階段之間來回傳遞錨定值的工作階段變數。如果您手動撰寫同步處理配接器命令,仍然可以使用 @sync\_new\_received\_anchor 和 @sync\_last\_received\_anchor 工作階段變數。@sync_max_received_anchor 工作階段變數只會由新的錨定命令所使用。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:指定變更的順序和批次大小。
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