Columns Propiedad
Obtiene una lista de los objetos DbSyncColumnDescription que representan las columnas de una tabla.
Espacio de nombres: Microsoft.Synchronization.Data
Ensamblado: Microsoft.Synchronization.Data (en Microsoft.Synchronization.Data.dll)
Sintaxis
'Declaración
Public ReadOnly Property Columns As DbSyncColumnDescriptionCollection
Get
'Uso
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
Valor de la propiedad
Tipo: Microsoft.Synchronization.Data. . :: . .DbSyncColumnDescriptionCollection
Lista de los objetos DbSyncColumnDescription que representan las columnas de una tabla.
Ejemplos
En el ejemplo de código siguiente se describe un ámbito denominado filtered_customer y se agregan tres tablas al mismo: Customer, CustomerContact y NewTable. Las dos primeras tablas ya existen en la base de datos servidor, de modo que el método GetDescriptionForTable se utiliza para recuperar el esquema de base de datos servidor. Se incluyen todas las columnas de la tabla Customer, pero solo se incluyen dos columnas de la tabla CustomerContact. La tabla NewTable se define usando los objetos DbSyncTableDescription y DbSyncColumnDescription y, a continuación, se crea la tabla en la base de datos servidor (y en las demás bases de datos que se sincronizan con ella). Para consultar este código en el contexto de un ejemplo completo, vea Configurar y ejecutar la sincronización de base de datos (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)