Share via


TableCreationOption Enumeration

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Defines the options that are available for creating a table in the client database.

Namespace: Microsoft.Synchronization.Data.Client
Assembly: Microsoft.Synchronization.Data (in microsoft.synchronization.data.dll)

Syntax

public enum TableCreationOption

Members

Member name Description
CreateNewTableOrFail Create the table in the client database. If an existing table has the same name, throw an exception.
DropExistingOrCreateNewTable Create the table in the client database. If an existing table has the same name, drop the existing table first.
TruncateExistingOrCreateNewTable Create the table in the client database if the table does not exist. If an existing table has the same name, delete all rows from this table.
UploadExistingOrCreateNewTable Create the table in the client database if the table does not exist. If an existing table has the same name, upload all rows from this table on the first synchronization. This option is only valid with a SyncTableTransferOption of Bidirectional or UploadOnly.
UseExistingTableOrFail Use an existing table in the client database that has the same name. If the table does not exist, throw an exception.

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.

Example

The following code example is from a class that derives from SqlCeClientSyncProvider. 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.SyncTableTransferOption = SyncTableTransferOption.DownloadOnly;
customerSyncTable.SyncGroup = customerSyncGroup;
this.Configuration.SyncTables.Add(customerSyncTable);

SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader");
orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderHeaderSyncTable.SyncTableTransferOption = SyncTableTransferOption.DownloadOnly;
orderHeaderSyncTable.SyncGroup = orderSyncGroup;
this.Configuration.SyncTables.Add(orderHeaderSyncTable);

SyncTable orderDetailSyncTable = new SyncTable("OrderDetail");
orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderDetailSyncTable.SyncTableTransferOption = SyncTableTransferOption.DownloadOnly;
orderDetailSyncTable.SyncGroup = orderSyncGroup;
this.Configuration.SyncTables.Add(orderDetailSyncTable);

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements (Sync Framework).

Target Platforms

See Also

Reference

Microsoft.Synchronization.Data.Client Namespace