SqlSyncScopeProvisioning::PopulateFromTemplate Method
Sets the template-based scope description from which the database should be provisioned.
Assembly: Microsoft.Synchronization.Data.SqlServer (in Microsoft.Synchronization.Data.SqlServer.dll)
Parameters
- scopeName
- Type: System::String
The name the scope.
- templateName
- Type: System::String
The name of the template.
The following example defines a parameter value for a filter, applies it to the server database, and provisions the client database with the filtered scope to ready it for synchronization.
// 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.UserComment = "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.UserComment = "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()
Show: