SyncTable.CreationOption Property

Gets or sets the TableCreationOption enumeration value that represents the action to take when you are creating tables in the client database.

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

Syntax

'Declaration
Public Property CreationOption As TableCreationOption
    Get
    Set
'Usage
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)

Property Value

Type: Microsoft.Synchronization.Data.TableCreationOption
A TableCreationOption enumeration value that represents the action to take when you are creating tables in the client database.

Remarks

The TableCreationOption property determines how to handle table creation in the client database, particularly as it relates to existing tables of the same name in the database. For more information, see How to: Initialize the Client Database and Work with Table Schema.

Examples

The following code example is from a class that derives from SyncAgent. The code creates two synchronization groups and three synchronization tables. The Customer table is added to the Customer group, and the OrderHeader and OrderDetail tables are added to the Order group. All tables are download-only. If a table exists at the client, the table is dropped and re-created during the initial synchronization. To view this code in the context of a complete example, see How to: Filter Rows and Columns.

//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)

See Also

Reference

SyncTable Class

Microsoft.Synchronization.Data Namespace