SyncParameters プロパティ

SyncParameter オブジェクトの SyncParameterCollection を取得または設定します。これらのオブジェクトは、サーバーでセッション変数として使用できます。

名前空間:  Microsoft.Synchronization.Data
アセンブリ:  Microsoft.Synchronization.Data (Microsoft.Synchronization.Data.dll 内)

構文

'宣言
Public Property SyncParameters As SyncParameterCollection
    Get
    Set
'使用
Dim instance As SyncSession
Dim value As SyncParameterCollection

value = instance.SyncParameters

instance.SyncParameters = value
public SyncParameterCollection SyncParameters { get; set; }
public:
property SyncParameterCollection^ SyncParameters {
    SyncParameterCollection^ get ();
    void set (SyncParameterCollection^ value);
}
member SyncParameters : SyncParameterCollection with get, set
function get SyncParameters () : SyncParameterCollection
function set SyncParameters (value : SyncParameterCollection)

プロパティ値

型 : Microsoft.Synchronization.Data. . :: . .SyncParameterCollection
SyncParameter オブジェクトの SyncParameterCollection

説明

同期パラメーターは、通常、同期エージェントにフィルター情報を渡すために使用されます。これらのパラメーターは、同期アダプターに対するコマンドに使用されます。

次のコード例では、SyncAgent から派生するクラスを示します。このコードでは、@SalesPerson パラメーターの値を指定する SyncParameter オブジェクトを作成します。アプリケーションによっては、この値をログイン ID やその他のユーザー入力によって設定できます。完全なコンテキスト例でコードを表示するには、「行および列をフィルター選択する方法」を参照してください。

this.Configuration.SyncParameters.Add(
    new SyncParameter("@SalesPerson", "Brenda Diaz"));
Me.Configuration.SyncParameters.Add(New SyncParameter("@SalesPerson", "Brenda Diaz"))

次のコード例では、DbServerSyncProvider から派生するクラスを示します。このコードでは、Customer テーブルについて、挿入されたどの列および行をダウンロードするかを指定します。SalesPerson の値はハードコーディングできますが、この例で示すように、変更可能な値が設定されたパラメーターを使用する方が一般的です。この例では、このフィルター パラメーターと共に、増分挿入のダウンロードに必要な他のパラメーターも渡しています。

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;
Dim customerIncrInserts As New SqlCommand()
With 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)"
    .Parameters.Add("@SalesPerson", SqlDbType.NVarChar)
    .Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp)
    .Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp)
    .Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier)
    .Connection = serverConn
End With
customerSyncAdapter.SelectIncrementalInsertsCommand = customerIncrInserts

参照

参照

SyncSessionクラス

SyncSession メンバー

Microsoft.Synchronization.Data 名前空間