共用方式為


SyncDirection 列舉型別

定義資料變更流動的方向 (從用戶端的觀點來看)。

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

語法

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

成員

成員名稱 描述
DownloadOnly 在第一次同步處理時,用戶端通常會從伺服器下載結構描述和初始資料集。後續進行同步處理時,用戶端會從伺服器下載變更。
UploadOnly 在第一次同步處理時,用戶端通常會從伺服器下載結構描述。後續進行同步處理時,用戶端會將變更上傳到伺服器。
Bidirectional 在第一次同步處理時,用戶端通常會從伺服器下載結構描述和初始資料集。後續進行同步處理時,用戶端會將變更上傳到伺服器,然後從伺服器下載變更。
Snapshot 用戶端會從伺服器下載一組資料,每一次同步處理時,都會完整重新整理這些資料。

備註

同步處理方向會決定在同步處理期間,要如何在用戶端與伺服器資料庫之間交換變更。如需詳細資訊,請參閱 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 命名空間