共用方式為


SqlSyncScopeProvisioning.SetCreateTableDefault 方法

設定是否要在已設定範圍時建立基底資料表。

命名空間: Microsoft.Synchronization.Data.SqlServer
組件: Microsoft.Synchronization.Data.SqlServer (在 microsoft.synchronization.data.sqlserver.dll)

語法

'宣告
Public Sub SetCreateTableDefault ( _
    defaultOption As DbSyncCreationOption _
)
'用途
Dim instance As SqlSyncScopeProvisioning
Dim defaultOption As DbSyncCreationOption

instance.SetCreateTableDefault(defaultOption)
public void SetCreateTableDefault (
    DbSyncCreationOption defaultOption
)
public:
void SetCreateTableDefault (
    DbSyncCreationOption defaultOption
)
public void SetCreateTableDefault (
    DbSyncCreationOption defaultOption
)
public function SetCreateTableDefault (
    defaultOption : DbSyncCreationOption
)

參數

備註

如果基底資料表已經存在資料庫中,而且您沒有使用 DbSyncTableDescription 物件來定義任何資料表結構描述,請指定 Skip 值。

範例

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