SqlSyncScopeProvisioning.PopulateFromTemplate Method
Sets the template-based scope description from which the database should be provisioned.
Namespace: Microsoft.Synchronization.Data.SqlServer
Assembly: Microsoft.Synchronization.Data.SqlServer (in Microsoft.Synchronization.Data.SqlServer.dll)
Syntax
'Declaration
Public Sub PopulateFromTemplate ( _
scopeName As String, _
templateName As String _
)
'Usage
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
)
Parameters
- scopeName
Type: System.String
The name the scope.
- templateName
Type: System.String
The name of the template.
Remarks
Templates are used to describe a parameter-based filtered scope. A filtered scope is then created by using PopulateFromTemplate to retrieve the template description, and by defining specific values for the parameters described in the template.
Examples
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()
See Also
Reference
SqlSyncScopeProvisioning Class
Microsoft.Synchronization.Data.SqlServer Namespace
Other Resources
How to: Filter Data for Database Synchronization (SQL Server)