Propriedade CreationOption
Obtém ou define um valor de enumeração TableCreationOption que representa a ação a ser executada quando você está criando tabelas no banco de dados do cliente.
Namespace: Microsoft.Synchronization.Data
Assembly: Microsoft.Synchronization.Data (em Microsoft.Synchronization.Data.dll)
Sintaxe
'Declaração
Public Property CreationOption As TableCreationOption
Get
Set
'Uso
Dim instance As SyncTable
Dim value As TableCreationOption
value = instance.CreationOption
instance.CreationOption = value
public TableCreationOption CreationOption { get; set; }
public:
property TableCreationOption CreationOption {
TableCreationOption get ();
void set (TableCreationOption value);
}
member CreationOption : TableCreationOption with get, set
function get CreationOption () : TableCreationOption
function set CreationOption (value : TableCreationOption)
Valor da propriedade
Tipo: Microsoft.Synchronization.Data. . :: . .TableCreationOption
Um valor de enumeração TableCreationOption que representa a ação a ser executada quando você está criando tabelas no banco de dados do cliente.
Comentários
A propriedade TableCreationOption determina como tratar a criação de tabelas no banco de dados do cliente, principalmente no que se refere a tabelas existentes com o mesmo nome no banco de dados. Para obter mais informações, consulte Como inicializar o banco de dados cliente e trabalhar com esquemas de tabela.
Exemplos
O exemplo de código a seguir é de uma classe derivada de SyncAgent. O código cria dois grupos de sincronização e três tabelas de sincronização. A tabela Customer é adicionada ao grupo Customer, e as tabelas OrderHeader e OrderDetail são adicionadas ao grupo Order. Todas as tabelas são somente para download. Se já existir uma tabela no cliente, ela será descartada e recriada durante a sincronização inicial. Para exibir esse código no contexto de um exemplo completo, consulte Como filtrar linhas e colunas.
//Create two SyncGroups so that changes to OrderHeader
//and OrderDetail are made in one transaction. Depending on
//application requirements, you might include Customer
//in the same group.
SyncGroup customerSyncGroup = new SyncGroup("Customer");
SyncGroup orderSyncGroup = new SyncGroup("Order");
//Add each table: specify a synchronization direction of
//DownloadOnly.
SyncTable customerSyncTable = new SyncTable("Customer");
customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
customerSyncTable.SyncDirection = SyncDirection.DownloadOnly;
customerSyncTable.SyncGroup = customerSyncGroup;
this.Configuration.SyncTables.Add(customerSyncTable);
SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader");
orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderHeaderSyncTable.SyncDirection = SyncDirection.DownloadOnly;
orderHeaderSyncTable.SyncGroup = orderSyncGroup;
this.Configuration.SyncTables.Add(orderHeaderSyncTable);
SyncTable orderDetailSyncTable = new SyncTable("OrderDetail");
orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderDetailSyncTable.SyncDirection = SyncDirection.DownloadOnly;
orderDetailSyncTable.SyncGroup = orderSyncGroup;
this.Configuration.SyncTables.Add(orderDetailSyncTable);
'Create two SyncGroups so that changes to OrderHeader
'and OrderDetail are made in one transaction. Depending on
'application requirements, you might include Customer
'in the same group.
Dim customerSyncGroup As New SyncGroup("Customer")
Dim orderSyncGroup As New SyncGroup("Order")
'Add each table: specify a synchronization direction of
'DownloadOnly.
Dim customerSyncTable As New SyncTable("Customer")
customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable
customerSyncTable.SyncDirection = SyncDirection.DownloadOnly
customerSyncTable.SyncGroup = customerSyncGroup
Me.Configuration.SyncTables.Add(customerSyncTable)
Dim orderHeaderSyncTable As New SyncTable("OrderHeader")
orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable
orderHeaderSyncTable.SyncDirection = SyncDirection.DownloadOnly
orderHeaderSyncTable.SyncGroup = orderSyncGroup
Me.Configuration.SyncTables.Add(orderHeaderSyncTable)
Dim orderDetailSyncTable As New SyncTable("OrderDetail")
orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable
orderDetailSyncTable.SyncDirection = SyncDirection.DownloadOnly
orderDetailSyncTable.SyncGroup = orderSyncGroup
Me.Configuration.SyncTables.Add(orderDetailSyncTable)