Partager via


Classe DbSyncScopeDescription

Représente une étendue de synchronisation, qui est un regroupement logique de tables (éventuellement filtrées) synchronisées en tant qu'unité.

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

Syntaxe

'Déclaration
<SerializableAttribute> _
Public Class DbSyncScopeDescription
'Utilisation
Dim instance As DbSyncScopeDescription
[SerializableAttribute]
public class DbSyncScopeDescription
[SerializableAttribute]
public ref class DbSyncScopeDescription
[<SerializableAttribute>]
type DbSyncScopeDescription =  class end
public class DbSyncScopeDescription

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) 

Hiérarchie d'héritage

System. . :: . .Object
  Microsoft.Synchronization.Data..::..DbSyncScopeDescription

Sécurité des threads

Tous les membres publics static (Shared dans Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi

Référence

Membres DbSyncScopeDescription

Espace de noms Microsoft.Synchronization.Data