SyncGroup 属性

获取或设置 SyncGroup 对象,该对象表示此 SyncTable 所属的组。

命名空间:  Microsoft.Synchronization.Data
程序集:  Microsoft.Synchronization.Data(在 Microsoft.Synchronization.Data.dll 中)

语法

声明
Public Property SyncGroup As SyncGroup
    Get
    Set
用法
Dim instance As SyncTable
Dim value As SyncGroup

value = instance.SyncGroup

instance.SyncGroup = value
public SyncGroup SyncGroup { get; set; }
public:
property SyncGroup^ SyncGroup {
    SyncGroup^ get ();
    void set (SyncGroup^ value);
}
member SyncGroup : SyncGroup with get, set
function get SyncGroup () : SyncGroup
function set SyncGroup (value : SyncGroup)

属性值

类型:Microsoft.Synchronization.Data. . :: . .SyncGroup
一个 SyncGroup 对象,表示此 SyncTable 所属的组。

异常

异常 条件
ArgumentException

value 为空或 null Nothing nullptr unit null 引用(在 Visual Basic 中为 Nothing) 。

注释

在定义了同步表之后,可以将其添加到同步组中。同步组是一种确保在一组表中一致地应用变更的机制。如果表包括在同步组中,则对这些表进行的变更将作为一个单元进行传送,而且会在单个事务中应用这些变更。如果组中进行的任何变更失败,则对整个组的变更都会在下一次同步时进行重试。

示例

下面的代码示例摘自从 SyncAgent 派生的类。代码创建两个同步组和三个同步表。Customer 表添加到 Customer 组,OrderHeader 和 OrderDetail 表添加到 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)

请参阅

参考

SyncTable类

SyncTable 成员

Microsoft.Synchronization.Data 命名空间