Classe DbSyncScopeDescription

Representa um escopo de sincronização, que é um agrupamento lógico de tabelas (opcionalmente filtradas) sincronizadas como uma unidade.

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (em Microsoft.Synchronization.Data.dll)

Sintaxe

'Declaração
<SerializableAttribute> _
Public Class DbSyncScopeDescription
'Uso
Dim instance As DbSyncScopeDescription
[SerializableAttribute]
public class DbSyncScopeDescription
[SerializableAttribute]
public ref class DbSyncScopeDescription
[<SerializableAttribute>]
type DbSyncScopeDescription =  class end
public class DbSyncScopeDescription

Exemplos

O exemplo de código a seguir descreve um escopo denominado filtered_customer e acrescenta três tabelas ao escopo: Customer, CustomerContact e NewTable. Como as duas primeiras tabelas já existem no banco de dados do servidor, o método GetDescriptionForTable é usado para recuperar o esquema do banco de dados do servidor. São incluídas todas as colunas da tabela Customer, mas apenas duas colunas da tabela CustomerContact são incluídas. A tabela NewTable é definida pelo uso dos objetos DbSyncTableDescription e DbSyncColumnDescription e a tabela é criada no banco de dados do servidor (e nos outros bancos de dados sincronizados com ele). Para exibir esse código no contexto de um exemplo completo, consulte Como configurar e executar a sincronização de bancos de dados (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) 

Hierarquia de herança

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

Segurança de thread

Quaisquer membros static (Shared no Visual Basic) públicos deste tipo são thread-safe. Não há garantia de que qualquer membro de instância seja thread-safe.

Consulte também

Referência

Membros DbSyncScopeDescription

Namespace Microsoft.Synchronization.Data