Freigeben über


Script-Methode

Generiert unter Verwendung der im Konstruktor angegebenen Verbindung eine Zeichenfolge, die den SQL-Code zur Bereitstellung der Datenbank für einen bestimmten Bereich enthält.

Namespace:  Microsoft.Synchronization.Data.SqlServer
Assembly:  Microsoft.Synchronization.Data.SqlServer (in Microsoft.Synchronization.Data.SqlServer.dll)

Syntax

'Declaration
Public Function Script As String
'Usage
Dim instance As SqlSyncScopeProvisioning
Dim returnValue As String

returnValue = instance.Script()
public string Script()
public:
String^ Script()
member Script : unit -> string 
public function Script() : String

Rückgabewert

Typ: System. . :: . .String
Der SQL-Code zur Bereitstellung der Datenbank.

Beispiele

Im folgenden Codebeispiel wird ein Bereitstellungsobjekt für den filtered_customer-Bereich erstellt und angegeben, dass alle synchronisierungsbezogenen Objekte in einem Datenbankschema mit der Bezeichnung "Sync" erstellt werden sollen. Als Teil der Bereitstellung des Bereichs wird mit dem Code ein Filter für die Customer-Tabelle definiert. Nur Zeilen, die mit dem Filter übereinstimmen, werden synchronisiert. Für die CustomerContact-Tabelle wird kein Filter definiert. Dadurch werden alle Zeilen aus dieser Tabelle synchronisiert. Nach der Definition der Bereitstellungsoptionen wird die Apply-Methode aufgerufen, um die Infrastruktur für die Änderungsnachverfolgung in der Serverdatenbank zu erstellen, und das Bereitstellungsskript wird in eine Datei geschrieben. Eine Darstellung dieses Codes im Kontext eines vollständigen Beispiels finden Sie unter Vorgehensweise: Konfigurieren und Ausführen der Datenbanksynchronisierung (SQL Server).

SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
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.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())

Siehe auch

Verweis

SqlSyncScopeProvisioning Klasse

SqlSyncScopeProvisioning-Member

Script-Überladung

Microsoft.Synchronization.Data.SqlServer-Namespace