GetDescriptionForTable 方法

返回一个 DbSyncTableDescription 对象,该对象包含 SQL Server 数据库中的表的相关架构信息。

重载列表

  名称 说明
公共方法静态成员 GetDescriptionForTable(String, SqlConnection) 返回一个 DbSyncTableDescription 对象,该对象包含 SQL Server 数据库中指定表的相关架构信息。
公共方法静态成员 GetDescriptionForTable(String, Collection< (Of < <' (String> ) > > ), SqlConnection) 返回一个 DbSyncTableDescription 对象,该对象包含 SQL Server 数据库中指定表的相关架构信息。

页首

注释

下面的代码示例描述名为 filtered_customer 的一个作用域,并且将两个表添加到该作用域:Customer 和 CustomerContact。这两个表已存在于服务器数据库中,因此,使用 GetDescriptionForTable 方法从服务器数据库中检索架构。将包括来自 Customer 表的所有列,但只包括来自 CustomerContact 表的两列。若要在完整示例上下文中查看此代码,请参见如何配置和执行数据库同步 (SQL Server)

DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("filtered_customer");

// Definition for Customer.
DbSyncTableDescription customerDescription =
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.Customer", serverConn);

scopeDesc.Tables.Add(customerDescription);

// Definition for CustomerContact, including the list of columns to include.
Collection<string> columnsToInclude = new Collection<string>();
columnsToInclude.Add("CustomerId");
columnsToInclude.Add("PhoneType");
DbSyncTableDescription customerContactDescription =
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.CustomerContact", columnsToInclude, serverConn);

scopeDesc.Tables.Add(customerContactDescription);
Dim scopeDesc As New DbSyncScopeDescription("filtered_customer")

' Definition for Customer. 
Dim customerDescription As DbSyncTableDescription = _
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.Customer", serverConn)

scopeDesc.Tables.Add(customerDescription)


' Definition for CustomerContact, including the list of columns to include. 
Dim columnsToInclude As New Collection(Of String)()
columnsToInclude.Add("CustomerId")
columnsToInclude.Add("PhoneType")
Dim customerContactDescription As DbSyncTableDescription = _
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.CustomerContact", columnsToInclude, serverConn)

scopeDesc.Tables.Add(customerContactDescription)

请参阅

参考

SqlSyncDescriptionBuilder类

SqlSyncDescriptionBuilder 成员

Microsoft.Synchronization.Data.SqlServer 命名空间