Share via


SqlSyncScopeProvisioning.Apply メソッド

指定された接続を使用して、準備スクリプトを SQL Server データベースに適用します。

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

構文

'宣言
Public Sub Apply ( _
    connection As SqlConnection _
)
'使用
Dim instance As SqlSyncScopeProvisioning
Dim connection As SqlConnection

instance.Apply(connection)
public void Apply (
    SqlConnection connection
)
public:
void Apply (
    SqlConnection^ connection
)
public void Apply (
    SqlConnection connection
)
public function Apply (
    connection : SqlConnection
)

パラメーター

  • connection
    データベースへの接続を格納する SqlConnection オブジェクト。

次のコード例は、filtered_customer スコープ用に準備オブジェクトを作成し、ベース テーブルがサーバー データベースに作成されないように指定します。さらに、同期に関連するオブジェクトはすべて "Sync" という名前のデータベース スキーマ内で作成されるように指定します。スコープを準備する処理の一環として、Customer テーブルに対するフィルターを定義します。このフィルターに一致した行だけが同期されます。CustomerContact テーブルにはフィルターを定義しません。したがって、このテーブルのすべての行が同期されます。準備オプションを定義した後、Apply メソッドを呼び出して、サーバー データベースに変更追跡インフラストラクチャを作成します。さらに、準備スクリプトをファイルに書き込みます。完全なコンテキスト例でこのコードを表示するには、「コラボレーション同期を構成して実行する方法 (SQL Server)」を参照してください。

SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(scopeDesc);
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
serverConfig.ObjectSchema = "Sync";

// Specify which column(s) in the Customer table to use for filtering data, 
// and the filtering clause to use against the tracking table.
// "[side]" is an alias for the tracking table.
serverConfig.Tables["Sales.Customer"].AddFilterColumn("CustomerType");
serverConfig.Tables["Sales.Customer"].FilterClause = "[side].[CustomerType] = 'Retail'";

// Configure the scope and change-tracking infrastructure.
serverConfig.Apply(serverConn);

// Write the configuration script to a file. You can modify 
// this script if necessary and run it against the server
// to customize behavior.
File.WriteAllText("SampleConfigScript.txt",
    serverConfig.Script("SyncSamplesDb_SqlPeer1"));
Dim serverConfig As New SqlSyncScopeProvisioning(scopeDesc)
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip)
serverConfig.ObjectSchema = "Sync"

' Specify which column(s) in the Customer table to use for filtering data, 
' and the filtering clause to use against the tracking table. 
' "[side]" is an alias for the tracking table. 
serverConfig.Tables("Sales.Customer").AddFilterColumn("CustomerType")
serverConfig.Tables("Sales.Customer").FilterClause = "[side].[CustomerType] = 'Retail'"

' Configure the scope and change-tracking infrastructure. 
serverConfig.Apply(serverConn)

' Write the configuration script to a file. You can modify 
' this script if necessary and run it against the server 
' to customize behavior. 
File.WriteAllText("SampleConfigScript.txt", serverConfig.Script("SyncSamplesDb_SqlPeer1"))

参照

リファレンス

SqlSyncScopeProvisioning クラス
SqlSyncScopeProvisioning メンバー
Microsoft.Synchronization.Data.SqlServer 名前空間