Apply 方法

通过在构造函数中指定的连接应用设置脚本。

命名空间:  Microsoft.Synchronization.Data.SqlServerCe
程序集:  Microsoft.Synchronization.Data.SqlServerCe(在 Microsoft.Synchronization.Data.SqlServerCe.dll 中)

语法

声明
Public Sub Apply
用法
Dim instance As SqlCeSyncScopeProvisioning

instance.Apply()
public void Apply()
public:
void Apply()
member Apply : unit -> unit 
public function Apply()

示例

下面的示例演示如何定义仅包括 Sales.Customer 表中 CustomerType 值为 Retail 的项的经过筛选的作用域。经过筛选的作用域随后将用于设置 SQL Azure 数据库和 SQL Server Compact 客户端数据库,以进行经过筛选的同步。

SqlSyncScopeProvisioning azureRetailCustomersScope = new SqlSyncScopeProvisioning(azureConn);
azureRetailCustomersScope.PopulateFromTemplate("RetailCustomers", "customertype_template");
azureRetailCustomersScope.Tables["Sales.Customer"].FilterParameters["@customertype"].Value = "Retail";
azureRetailCustomersScope.UserDescription = "Customer data includes only retail customers.";
azureRetailCustomersScope.Apply();

// Create a SQL Server Compact database and provision it based on the retail customer scope
// retrieved from the SQL Azure database.
SqlCeConnection clientSqlCeConn = new SqlCeConnection(Utility.ConnStr_SqlCeSync1);
Utility.DeleteAndRecreateCompactDatabase(Utility.ConnStr_SqlCeSync1, true);

DbSyncScopeDescription azureRetailCustomersDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope("RetailCustomers", azureConn); 
SqlCeSyncScopeProvisioning clientSqlCeConfig = new SqlCeSyncScopeProvisioning(clientSqlCeConn, azureRetailCustomersDesc);
clientSqlCeConfig.Apply();
Dim azureRetailCustomersScope As New SqlSyncScopeProvisioning(azureConn)
azureRetailCustomersScope.PopulateFromTemplate("RetailCustomers", "customertype_template")
azureRetailCustomersScope.Tables("Sales.Customer").FilterParameters("@customertype").Value = "Retail"
azureRetailCustomersScope.UserDescription = "Customer data includes only retail customers."
azureRetailCustomersScope.Apply()

' Create a SQL Server Compact database and provision it based on the retail customer scope
' retrieved from the SQL Azure database.
Dim clientSqlCeConn As New SqlCeConnection(Utility.ConnStr_SqlCeSync1)
Utility.DeleteAndRecreateCompactDatabase(Utility.ConnStr_SqlCeSync1, True)

Dim azureRetailCustomersDesc As DbSyncScopeDescription = SqlSyncDescriptionBuilder.GetDescriptionForScope("RetailCustomers", azureConn)
Dim clientSqlCeConfig As New SqlCeSyncScopeProvisioning(clientSqlCeConn, azureRetailCustomersDesc)
clientSqlCeConfig.Apply()

请参阅

参考

SqlCeSyncScopeProvisioning类

SqlCeSyncScopeProvisioning 成员

Apply 重载

Microsoft.Synchronization.Data.SqlServerCe 命名空间