Export (0) Print
Expand All

SyncSession.SyncParameters Property

Synchronization Services - ADO.NET 1.0 SP1

Gets or sets a SyncParameterCollection of SyncParameter objects. These objects are available at the server as session variables.

Namespace: Microsoft.Synchronization.Data
Assembly: Microsoft.Synchronization.Data (in microsoft.synchronization.data.dll)

public SyncParameterCollection SyncParameters { get; set; }
/** @property */
public SyncParameterCollection get_SyncParameters ()

/** @property */
public void set_SyncParameters (SyncParameterCollection value)

public function get SyncParameters () : SyncParameterCollection

public function set SyncParameters (value : SyncParameterCollection)

Property Value

A SyncParameterCollection of SyncParameter objects.

Synchronization parameters are typically used to pass filtering information to the synchronization agent. These parameters are then used in commands for the synchronization adapter.

The following code example is from a class that derives from SyncAgent. This code creates a SyncParameter object that specifies a value for the @SalesPerson parameter. In an application, this value might come from a login ID or other user input. To view code in the context of a complete example, see How to: Filter Rows and Columns.

    new SyncParameter("@SalesPerson", "Brenda Diaz"));

The following code example is from a class that derives from DbServerSyncProvider. This code specifies which inserted columns and rows to download for the Customer table. You can hardcode a value for SalesPerson. However, it is more common to use a parameter that has a value that can change, as shown in the example. The example passes the filter parameter together with the other parameters that are required to download incremental inserts.

SqlCommand customerIncrInserts = new SqlCommand();
customerIncrInserts.CommandText =
    "SELECT CustomerId, CustomerName, CustomerType " +
    "FROM Sales.Customer " +
    "WHERE SalesPerson = @SalesPerson " +
    "AND (InsertTimestamp > @sync_last_received_anchor " +
    "AND InsertTimestamp <= @sync_new_received_anchor " +
    "AND InsertId <> @sync_client_id)";
customerIncrInserts.Parameters.Add("@SalesPerson", SqlDbType.NVarChar);
customerIncrInserts.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp);
customerIncrInserts.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp);
customerIncrInserts.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
customerIncrInserts.Connection = serverConn;
customerSyncAdapter.SelectIncrementalInsertsCommand = customerIncrInserts;

© 2015 Microsoft