DbServerSyncProvider.BatchSize Property
Gets or sets the batch size (in rows) that is used by commands that retrieve changes from the server database.
Namespace: Microsoft.Synchronization.Data.Server
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)
Syntax
'Declaration
Public Property BatchSize As Integer
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)
Property Value
The batch size (in rows) that is used by commands that retrieve changes from the server database.
Remarks
Synchronization Services enables applications to download batches of changes to the client (batching is not supported on upload). Batching is enabled by specifying a value for the BatchSize property, and creating a command for the SelectNewAnchorCommand property that can return anchor values for each batch of changes. For more information, see How to: Specify the Order and Batch Size of Changes.
Example
The following code example creates an anchor command that can be used if changes are delivered in batches. Instead of returning a new anchor value once for the whole set of changes, it returns a new anchor value for each batch of changes. The example uses the BatchSize property to specify how many changes should be in each batch, and session variables to pass anchor values back and forth between a stored procedure and the synchronization runtime. If you write synchronization adapter commands manually, you still use the @sync_new_received_anchor and @sync_last_received_anchor session variables. The @sync_max_received_anchor session variable is used only by the new anchor command. To view this code in the context of a complete example, see How to: Specify the Order and Batch Size of Changes.
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
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements (Synchronization Services).
Target Platforms
See Also
Reference
DbServerSyncProvider Class
DbServerSyncProvider Members
Microsoft.Synchronization.Data.Server Namespace