Share via


DbSyncTableDescription-Klasse

Stellt das Schema einer Tabelle dar, die in der Liste Tables eines DbSyncScopeDescription-Objekts enthalten ist. Dies wird beim Bereitstellen der Datenbank verwendet.

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

Syntax

'Declaration
<SerializableAttribute> _
Public Class DbSyncTableDescription
'Usage
Dim instance As DbSyncTableDescription
[SerializableAttribute]
public class DbSyncTableDescription
[SerializableAttribute]
public ref class DbSyncTableDescription
[<SerializableAttribute>]
type DbSyncTableDescription =  class end
public class DbSyncTableDescription

Beispiele

Im folgenden Codebeispiel wird ein Bereich mit dem Namen filtered_customer beschrieben, dem drei Tabellen hinzugefügt werden: Customer, CustomerContact und NewTable. Die ersten beiden Tabellen sind bereits in der Serverdatenbank vorhanden. Deshalb wird die GetDescriptionForTable-Methode verwendet, um das Schema aus der Serverdatenbank abzurufen. Aus der Customer-Tabelle sind alle Spalten enthalten, aus der CustomerContact-Tabelle jedoch nur zwei Spalten. Die NewTable-Tabelle wird mit DbSyncTableDescription-Objekten und DbSyncColumnDescription-Objekten definiert. Anschließend wird die Tabelle in der Serverdatenbank (sowie in den anderen damit synchronisierten Datenbanken) erstellt. Eine Darstellung dieses Codes im Kontext eines vollständigen Beispiels finden Sie unter Vorgehensweise: Konfigurieren und Ausführen der Datenbanksynchronisierung (SQL Server).

DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("filtered_customer");

// Definition for Customer.
DbSyncTableDescription customerDescription =
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.Customer", serverConn);
scopeDesc.Tables.Add(customerDescription);


// Definition for CustomerContact, including the list of columns to include.
Collection<string> columnsToInclude = new Collection<string>();
columnsToInclude.Add("CustomerId");
columnsToInclude.Add("PhoneType");
DbSyncTableDescription customerContactDescription =
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.CustomerContact", columnsToInclude, serverConn);

scopeDesc.Tables.Add(customerContactDescription);

DbSyncTableDescription newTableDescription = new DbSyncTableDescription("Sales.NewTable");

DbSyncColumnDescription newTableIdCol = new DbSyncColumnDescription();
DbSyncColumnDescription newTableContentCol = new DbSyncColumnDescription();

newTableIdCol.UnquotedName = "NewTableId";
newTableIdCol.Type = "int";
newTableIdCol.IsPrimaryKey = true;

newTableContentCol.UnquotedName = "NewTableContent";
newTableContentCol.Type = "nvarchar";
newTableContentCol.Size = "100";
newTableContentCol.IsPrimaryKey = false;

newTableDescription.Columns.Add(newTableIdCol);
newTableDescription.Columns.Add(newTableContentCol);
scopeDesc.Tables.Add(newTableDescription);
Dim scopeDesc As New DbSyncScopeDescription("filtered_customer")

' Definition for Customer. 
Dim customerDescription As DbSyncTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.Customer", serverConn)
scopeDesc.Tables.Add(customerDescription) 


' Definition for CustomerContact, including the list of columns to include. 
Dim columnsToInclude As New Collection(Of String)()
columnsToInclude.Add("CustomerId") 
columnsToInclude.Add("PhoneType") 
Dim customerContactDescription As DbSyncTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.CustomerContact", columnsToInclude, serverConn)

scopeDesc.Tables.Add(customerContactDescription) 

Dim newTableDescription As New DbSyncTableDescription("Sales.NewTable")

Dim newTableIdCol As New DbSyncColumnDescription()
Dim newTableContentCol As New DbSyncColumnDescription()

newTableIdCol.UnquotedName = "NewTableId" 
newTableIdCol.Type = "int" 
newTableIdCol.IsPrimaryKey = True 

newTableContentCol.UnquotedName = "NewTableContent" 
newTableContentCol.Type = "nvarchar" 
newTableContentCol.Size = "100" 
newTableContentCol.IsPrimaryKey = False 

newTableDescription.Columns.Add(newTableIdCol) 
newTableDescription.Columns.Add(newTableContentCol) 
scopeDesc.Tables.Add(newTableDescription) 

Vererbungshierarchie

System. . :: . .Object
  Microsoft.Synchronization.Data..::..DbSyncTableDescription

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

DbSyncTableDescription-Member

Microsoft.Synchronization.Data-Namespace