Share via


SqlSyncScopeProvisioning 類別

表示針對 DbSyncScopeDescription 物件所代表的特定範圍佈建 SQL Server 資料庫。

命名空間:  Microsoft.Synchronization.Data.SqlServer
組件:  Microsoft.Synchronization.Data.SqlServer (在 Microsoft.Synchronization.Data.SqlServer.dll 中)

語法

'宣告
Public Class SqlSyncScopeProvisioning
'用途
Dim instance As SqlSyncScopeProvisioning
public class SqlSyncScopeProvisioning
public ref class SqlSyncScopeProvisioning
type SqlSyncScopeProvisioning =  class end
public class SqlSyncScopeProvisioning

範例

下列程式碼範例會針對 filtered_customer 範圍建立佈建物件、指定不應該在伺服器資料庫中建立基底資料表,並且指定應該在名為 "Sync" 的資料庫結構描述中建立所有同步處理相關的物件。此程式碼會在 Customer 資料表上定義篩選,這是佈建範圍的一部分。只有符合該篩選的資料列才會同步處理。CustomerContact 資料表上未定義任何篩選,因此,該資料表中的所有資料列都將同步處理。在定義佈建選項之後,便會呼叫 Apply 方法在伺服器資料庫中建立變更追蹤基礎結構,而且佈建指令碼會寫入檔案中。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:設定及執行資料庫同步處理 (SQL Server)

SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(serverConn, 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();

// 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());
Dim serverConfig As New SqlSyncScopeProvisioning(serverConn, 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()

' 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())

繼承階層

System. . :: . .Object
  Microsoft.Synchronization.Data.SqlServer..::..SqlSyncScopeProvisioning

執行緒安全性

這個類型的任何公用static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員都可以是安全執行緒。

請參閱

參考

SqlSyncScopeProvisioning 成員

Microsoft.Synchronization.Data.SqlServer 命名空間