PopulateFromTemplate 方法
設定應該用來佈建資料庫的範本型範圍說明。
命名空間: Microsoft.Synchronization.Data.SqlServer
組件: Microsoft.Synchronization.Data.SqlServer (在 Microsoft.Synchronization.Data.SqlServer.dll 中)
語法
'宣告
Public Sub PopulateFromTemplate ( _
scopeName As String, _
templateName As String _
)
'用途
Dim instance As SqlSyncScopeProvisioning
Dim scopeName As String
Dim templateName As String
instance.PopulateFromTemplate(scopeName, _
templateName)
public void PopulateFromTemplate(
string scopeName,
string templateName
)
public:
void PopulateFromTemplate(
String^ scopeName,
String^ templateName
)
member PopulateFromTemplate :
scopeName:string *
templateName:string -> unit
public function PopulateFromTemplate(
scopeName : String,
templateName : String
)
參數
- scopeName
型別:System. . :: . .String
範圍的名稱。
- templateName
型別:System. . :: . .String
範本的名稱。
備註
範本是用來描述以參數為基礎的篩選範圍。然後會建立篩選範圍,其方式是使用 PopulateFromTemplate 擷取範本說明,以及針對範本中描述的參數來定義特定的值。
範例
下列範例會定義篩選的參數值、將它套用至伺服器資料庫,並且使用篩選範圍來佈建用戶端資料庫,讓資料庫可進行同步處理。
// Create a synchronization scope for retail customers.
// This action adds rows to synchronization tables but does not create new tables or stored procedures, reducing
// the permissions needed on the server.
SqlSyncScopeProvisioning serverProvRetail = new SqlSyncScopeProvisioning(serverConn);
serverProvRetail.ObjectSchema = "Sync";
serverProvRetail.PopulateFromTemplate("RetailCustomers", "customertype_template");
serverProvRetail.Tables["Sales.Customer"].FilterParameters["@customertype"].Value = "Retail";
serverProvRetail.UserDescription = "Customer data includes only retail customers.";
serverProvRetail.Apply();
// Provision the existing database SyncSamplesDb_SqlPeer2 based on filtered scope
// information that is retrieved from the server.
DbSyncScopeDescription clientSqlDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope("RetailCustomers", null, "Sync", serverConn);
SqlSyncScopeProvisioning clientSqlConfig = new SqlSyncScopeProvisioning(clientSqlConn, clientSqlDesc);
clientSqlConfig.ObjectSchema = "Sync";
clientSqlConfig.Apply();
' Create a synchronization scope for retail customers.
' This action adds rows to synchronization tables but does not create new tables or stored procedures, reducing
' the permissions needed on the server.
Dim serverProvRetail As New SqlSyncScopeProvisioning(serverConn)
serverProvRetail.ObjectSchema = "Sync"
serverProvRetail.PopulateFromTemplate("RetailCustomers", "customertype_template")
serverProvRetail.Tables("Sales.Customer").FilterParameters("@customertype").Value = "Retail"
serverProvRetail.UserDescription = "Customer data includes only retail customers."
serverProvRetail.Apply()
' Provision the existing database SyncSamplesDb_SqlPeer2 based on filtered scope
' information that is retrieved from the server.
Dim clientSqlDesc As DbSyncScopeDescription = SqlSyncDescriptionBuilder.GetDescriptionForScope("RetailCustomers", Nothing, "Sync", serverConn)
Dim clientSqlConfig As New SqlSyncScopeProvisioning(clientSqlConn, clientSqlDesc)
clientSqlConfig.ObjectSchema = "Sync"
clientSqlConfig.Apply()
請參閱
參考
Microsoft.Synchronization.Data.SqlServer 命名空間