DbSyncColumnDescription Clase
Representa el esquema de una columna que está incluida en la lista de Columns de un objeto DbSyncTableDescription. Se utiliza durante el aprovisionamiento de la base de datos.
Espacio de nombres: Microsoft.Synchronization.Data
Ensamblado: Microsoft.Synchronization.Data (en Microsoft.Synchronization.Data.dll)
Sintaxis
'Declaración
<SerializableAttribute> _
Public Class DbSyncColumnDescription
'Uso
Dim instance As DbSyncColumnDescription
[SerializableAttribute]
public class DbSyncColumnDescription
[SerializableAttribute]
public ref class DbSyncColumnDescription
[<SerializableAttribute>]
type DbSyncColumnDescription = class end
public class DbSyncColumnDescription
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)
Jerarquía de herencia
System. . :: . .Object
Microsoft.Synchronization.Data..::..DbSyncColumnDescription
Seguridad para subprocesos
Todos los miembros públicos static (Shared en Visual Basic) de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.