Share via


DbSyncAdapter クラス

ローカル ピア データベースでのデータ変更およびメタデータ変更の取得と適用に使用される一連のコマンドを表します。

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

構文

'宣言
<SuppressMessageAttribute("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase")> _
Public Class DbSyncAdapter
'使用
Dim instance As DbSyncAdapter
[SuppressMessageAttribute("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase")] 
public class DbSyncAdapter
[SuppressMessageAttribute(L"Microsoft.Naming", L"CA1706:ShortAcronymsShouldBeUppercase")] 
public ref class DbSyncAdapter
/** @attribute SuppressMessageAttribute("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase") */ 
public class DbSyncAdapter
SuppressMessageAttribute("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase") 
public class DbSyncAdapter

解説

DbSyncAdapterDbSyncProvider とピア データベースの間のブリッジとして機能します。同期アダプターは、ADO.NET のデータ アダプターをモデルとしており、同期対象のテーブルごとに定義します。一方のピア データベースから他方のピア データベースに挿入を適用する InsertCommand など、ピア データベースの操作に必要な特定のコマンドが同期アダプターによってピア同期プロバイダーに提供されます。同期アダプターでは ADO.NETDbCommand オブジェクトが使用されるので、ADO.NET によってサポートされる任意のコマンド構造を使用できます。この構造には、インライン Transact-SQL、ストアド プロシージャ、ビュー、関数などが含まれます。コマンドが必要とするのは、転送および適用に使用する構造とデータを定義するための、単一の結果のみです。

次のコード例では、Customer テーブルの SyncAdapter オブジェクトを作成し、CustomerId 列を使用してテーブルの各行を識別するように指定して、SelectIncrementalChangesCommand プロパティのコマンドを指定します。呼び出されるストアド プロシージャは、「データベース プロバイダーのセットアップ スクリプトに関するトピック」で定義したものです。アダプター コマンドの詳細、および完全なコンテキスト例でこのコードを表示する方法については、「コラボレーション同期用にサーバー データベースを準備する方法 (SQL Server 以外)」を参照してください。

DbSyncAdapter adapterCustomer = new DbSyncAdapter("Customer");


//Specify the primary key, which Sync Framework uses
//to identify each row during synchronization.
adapterCustomer.RowIdColumns.Add("CustomerId");
SqlCommand chgsCustomerCmd = new SqlCommand();
chgsCustomerCmd.CommandType = CommandType.StoredProcedure;
chgsCustomerCmd.CommandText = "Sync.sp_Customer_SelectChanges";
chgsCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncMetadataOnly, SqlDbType.Int);
chgsCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncMinTimestamp, SqlDbType.BigInt);
chgsCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncScopeLocalId, SqlDbType.Int);
chgsCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncInitialize, SqlDbType.Int);

adapterCustomer.SelectIncrementalChangesCommand = chgsCustomerCmd;
Dim adapterCustomer As New DbSyncAdapter("Customer")

'Specify the primary key, which Sync Framework uses
'to identify each row during synchronization.
adapterCustomer.RowIdColumns.Add("CustomerId")
Dim chgsCustomerCmd As New SqlCommand()

With chgsCustomerCmd
    .CommandType = CommandType.StoredProcedure
    .CommandText = "Sync.sp_Customer_SelectChanges"
    .Parameters.Add("@" + DbSyncSession.SyncMetadataOnly, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncMinTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncScopeLocalId, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncInitialize, SqlDbType.Int)
End With

adapterCustomer.SelectIncrementalChangesCommand = chgsCustomerCmd

継承階層

System.Object
  Microsoft.Synchronization.Data.DbSyncAdapter

スレッド セーフ

この型の public static (Visual Basic では Shared ) メンバーはすべて、スレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

参照

リファレンス

DbSyncAdapter メンバー
Microsoft.Synchronization.Data 名前空間