Метод 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 пустая ссылка (Nothing в Visual Basic) или является пустым. |
Примеры
В следующем примере кода создается объект провизионирования для области 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())
См. также
Справочник
SqlSyncScopeProvisioning Класс