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
public enum SyncDirection
public enum SyncDirection

成员

  成员名称 说明
Bidirectional 首次同步期间,客户端通常从服务器下载架构和一个初始数据集。执行后续同步时,客户端将变更上载到服务器,然后从服务器下载变更。 
DownloadOnly 首次同步期间,客户端通常从服务器下载架构和一个初始数据集。执行后续同步时,客户端从服务器下载变更。 
Snapshot 客户端将从服务器下载一个数据集。每次同步期间,这些数据都将完全刷新。 
UploadOnly 首次同步期间,客户端通常从服务器下载架构。执行后续同步时,客户端将变更上载到服务器。 

备注

同步方向确定同步期间在客户端和服务器数据库之间交换变更的方式。有关更多信息,请参见如何指定快照同步、下载同步、上载同步和双向同步

示例

下面的代码示例摘自从 SyncAgent 派生的类。代码创建两个同步组和三个同步表。Customer 表添加到 Customer 组,OrderHeaderOrderDetail 表添加到 Order 组。所有表都仅限下载。如果某个表在客户端存在,则会在初始同步期间删除并重新创建该表。若要在完整示例上下文中查看此代码,请参见如何筛选行和列

//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 命名空间