SyncParameter クラス
クライアントからサーバーに送信された情報をカプセル化します。
名前空間: Microsoft.Synchronization.Data
アセンブリ: Microsoft.Synchronization.Data (Microsoft.Synchronization.Data.dll 内)
構文
'宣言
<SerializableAttribute> _
Public Class SyncParameter
'使用
Dim instance As SyncParameter
[SerializableAttribute]
public class SyncParameter
[SerializableAttribute]
public ref class SyncParameter
[<SerializableAttribute>]
type SyncParameter = class end
public class SyncParameter
説明
同期パラメーターは、通常、同期エージェントにフィルター情報を渡すために使用されます。これらのパラメーターは、同期アダプターに対するコマンドに使用されます。
例
次のコード例では、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
継承階層
System. . :: . .Object
Microsoft.Synchronization.Data..::..SyncParameter
スレッド セーフ
この型の public static (Visual Basic では Shared) のメンバーはスレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。