次の方法で共有


GetDescriptionForTable メソッド

SQL Server データベース内のテーブルに関するスキーマ情報を格納する DbSyncTableDescription オブジェクトを返します。

オーバーロードの一覧

  名前 説明
パブリック メソッド静的メンバー GetDescriptionForTable(String, SqlConnection) SQL Server データベース内の指定されたテーブルに関するスキーマ情報を格納する DbSyncTableDescription オブジェクトを返します。
パブリック メソッド静的メンバー GetDescriptionForTable(String, Collection< (Of < <' (String> ) > > ), SqlConnection) SQL Server データベース内の指定されたテーブルに関するスキーマ情報を格納する DbSyncTableDescription オブジェクトを返します。

Top

説明

次のコード例では、filtered_customer という名前のスコープを記述し、このスコープに 2 つのテーブル Customer と CustomerContact を追加します。このテーブルは既にサーバー データベースに存在しているので、GetDescriptionForTable メソッドを使用して、サーバー データベースからスキーマを取得します。Customer テーブルのすべての列が含まれますが、CustomerContact テーブルの列は 2 つしか含まれません。完全なコンテキスト例でこのコードを表示するには、「方法: データベース同期を構成して実行する (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 名前空間