Share via


Tables Propiedad

Obtiene o establece una lista de objetos DbSyncTableDescription que representa las tablas del ámbito.

Espacio de nombres:  Microsoft.Synchronization.Data
Ensamblado:  Microsoft.Synchronization.Data (en Microsoft.Synchronization.Data.dll)

Sintaxis

'Declaración
Public ReadOnly Property Tables As DbSyncTableDescriptionCollection
    Get
'Uso
Dim instance As DbSyncScopeDescription
Dim value As DbSyncTableDescriptionCollection

value = instance.Tables
public DbSyncTableDescriptionCollection Tables { get; }
public:
property DbSyncTableDescriptionCollection^ Tables {
    DbSyncTableDescriptionCollection^ get ();
}
member Tables : DbSyncTableDescriptionCollection
function get Tables () : DbSyncTableDescriptionCollection

Valor de la propiedad

Tipo: Microsoft.Synchronization.Data. . :: . .DbSyncTableDescriptionCollection
Lista de objetos DbSyncTableDescription que representa las tablas del ámbito.

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) 

Vea también

Referencia

DbSyncScopeDescription Clase

DbSyncScopeDescription Miembros

Microsoft.Synchronization.Data Espacio de nombres