Script 方法 (String)
注意:此 API 现已过时。
生成一个字符串,该字符串包含用于针对特定作用域设置数据库的 SQL 代码。
命名空间: Microsoft.Synchronization.Data.SqlServer
程序集: Microsoft.Synchronization.Data.SqlServer(在 Microsoft.Synchronization.Data.SqlServer.dll 中)
语法
声明
<ObsoleteAttribute("Use Constructor with SqlConnection and Script()")> _
Public Function Script ( _
targetDatabaseName As String _
) As String
用法
Dim instance As SqlSyncScopeProvisioning
Dim targetDatabaseName As String
Dim returnValue As String
returnValue = instance.Script(targetDatabaseName)
[ObsoleteAttribute("Use Constructor with SqlConnection and Script()")]
public string Script(
string targetDatabaseName
)
[ObsoleteAttribute(L"Use Constructor with SqlConnection and Script()")]
public:
String^ Script(
String^ targetDatabaseName
)
[<ObsoleteAttribute("Use Constructor with SqlConnection and Script()")>]
member Script :
targetDatabaseName:string -> string
public function Script(
targetDatabaseName : String
) : String
参数
- targetDatabaseName
类型:System. . :: . .String
应为其生成设置脚本的数据库的名称。
返回值
类型:System. . :: . .String
用于针对特定作用域设置数据库的 SQL 代码。
异常
异常 | 条件 |
---|---|
ArgumentException | targetDatabaseName 为 null Nothing nullptr unit null 引用(在 Visual Basic 中为 Nothing) 或空。 |
示例
下面的代码示例为 filtered_customer 作用域创建一个设置对象,指定基表不应在服务器数据库中创建,并且指定与同步相关的所有对象都应在名为 "Sync" 的数据库架构中创建。作为作用域设置的一部分,该代码对 Customer 表定义一个筛选器。将只同步与该筛选器匹配的行。没有对 CustomerContact 表定义任何筛选器;因此,将同步来自该表的所有行。在定义设置选项后,调用 Apply 方法以便在服务器数据库中创建变更跟踪基础结构;并且设置脚本将写入某一文件。若要在完整示例上下文中查看此代码,请参见如何配置和执行数据库同步 (SQL Server)。
SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(serverConn, 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();
// 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());
Dim serverConfig As New SqlSyncScopeProvisioning(serverConn, 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()
' 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())