共用方式為


TableCreationOption 列舉型別

定義在用戶端資料庫中建立資料表的可用選項。

命名空間:  Microsoft.Synchronization.Data
組件:  Microsoft.Synchronization.Data (在 Microsoft.Synchronization.Data.dll 中)

語法

'宣告
Public Enumeration TableCreationOption
'用途
Dim instance As TableCreationOption
public enum TableCreationOption
public enum class TableCreationOption
type TableCreationOption
public enum TableCreationOption

成員

成員名稱 描述
CreateNewTableOrFail 在用戶端資料庫中建立資料表。如果有同名的資料表存在,則會擲回例外狀況 (Exception)。
UseExistingTableOrFail 使用用戶端資料庫中同名的現有資料表。如果此資料表不存在,則會擲回例外狀況。
TruncateExistingOrCreateNewTable 在用戶端資料庫中建立資料表 (如果該資料表不存在)。如果有同名的資料表存在,請刪除這個資料表中的所有資料列。
DropExistingOrCreateNewTable 在用戶端資料庫中建立資料表。如果有同名的資料表存在,請先卸除這個現有的資料表。
UploadExistingOrCreateNewTable 在用戶端資料庫中建立資料表 (如果該資料表不存在)。如果有同名的資料表存在,請在第一次同步處理時上傳這個資料表中的所有資料列。這個選項只有在搭配 BidirectionalUploadOnlySyncDirection 時才有效。

備註

TableCreationOption 屬性會判斷如何在用戶端資料庫中處理資料表建立,特別是當它與資料庫中同名的現有資料表相關時。如需詳細資訊,請參閱 HOW TO:初始化用戶端資料庫及使用資料表結構描述

範例

下列程式碼範例來自衍生自 SyncAgent 的類別。此程式碼會建立兩個同步處理群組及三個同步處理資料表。Customer 資料表會加入 Customer 群組,而 OrderHeader 和 OrderDetail 資料表會加入 Order 群組。所有的資料表僅供下載。如果用戶端上有資料表存在,則會卸除此資料表,並在初始同步處理期間重新建立。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:篩選資料列和資料行

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

請參閱

參考

Microsoft.Synchronization.Data 命名空間