Partager via


Tables propriété

Obtient ou définit une liste d'objets DbSyncTableDescription qui représente les tables dans l'étendue.

Espace de noms :  Microsoft.Synchronization.Data
Assembly :  Microsoft.Synchronization.Data (dans Microsoft.Synchronization.Data.dll)

Syntaxe

'Déclaration
Public ReadOnly Property Tables As DbSyncTableDescriptionCollection
    Get
'Utilisation
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

Valeur de la propriété

Type : Microsoft.Synchronization.Data. . :: . .DbSyncTableDescriptionCollection
Liste d'objets DbSyncTableDescription qui représente les tables dans l'étendue.

Exemples

L'exemple de code suivant décrit une étendue nommée filtered_customer et ajoute trois tables à l'étendue : Customer, CustomerContact et NewTable. Les deux premières tables existent déjà dans la base de données serveur, de sorte que la méthode GetDescriptionForTable est utilisée pour récupérer le schéma de la base de données serveur. Toutes les colonnes de la table Customer sont incluses, mais seules deux colonnes de la table CustomerContact sont incluses. La table NewTable est définie à l'aide des objets DbSyncTableDescription et DbSyncColumnDescription, puis, la table est créée dans la base de données serveur (et dans les autres bases de données qui synchronisent avec lui). Pour afficher ce code dans le contexte d'un exemple complet, consultez Procédure : configurer et exécuter la synchronisation de bases de données (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) 

Voir aussi

Référence

DbSyncScopeDescription Classe

Membres DbSyncScopeDescription

Espace de noms Microsoft.Synchronization.Data