Columns-Eigenschaft
Ruft eine Liste von DbSyncColumnDescription-Objekten ab, die die Spalten in einer Tabelle darstellen.
Namespace: Microsoft.Synchronization.Data
Assembly: Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)
Syntax
'Declaration
Public ReadOnly Property Columns As DbSyncColumnDescriptionCollection
Get
'Usage
Dim instance As DbSyncTableDescription
Dim value As DbSyncColumnDescriptionCollection
value = instance.Columns
public DbSyncColumnDescriptionCollection Columns { get; }
public:
property DbSyncColumnDescriptionCollection^ Columns {
DbSyncColumnDescriptionCollection^ get ();
}
member Columns : DbSyncColumnDescriptionCollection
function get Columns () : DbSyncColumnDescriptionCollection
Eigenschaftenwert
Typ: Microsoft.Synchronization.Data. . :: . .DbSyncColumnDescriptionCollection
Eine Liste von DbSyncColumnDescription-Objekten, die die Spalten in einer Tabelle darstellen.
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)