Share via


DbSyncTableDescription クラス

DbSyncScopeDescription オブジェクトの Tables の一覧に含まれるテーブルのスキーマを表します。これはデータベースの準備中に使用されます。

名前空間:  Microsoft.Synchronization.Data
アセンブリ:  Microsoft.Synchronization.Data (Microsoft.Synchronization.Data.dll 内)

構文

'宣言
<SerializableAttribute> _
Public Class DbSyncTableDescription
'使用
Dim instance As DbSyncTableDescription
[SerializableAttribute]
public class DbSyncTableDescription
[SerializableAttribute]
public ref class DbSyncTableDescription
[<SerializableAttribute>]
type DbSyncTableDescription =  class end
public class DbSyncTableDescription

次のコード例では、filtered_customer という名前のスコープを記述し、このスコープに 3 つのテーブル Customer、CustomerContact、および NewTable を追加します。最初の 2 つのテーブルは既にサーバー データベースに存在しています。そのため、スキーマは GetDescriptionForTable メソッドを使用して、サーバー データベースから取得します。Customer テーブルのすべての列が含まれますが、CustomerContact テーブルの列は 2 つしか含まれません。NewTable テーブルは、DbSyncTableDescription オブジェクトと DbSyncColumnDescription オブジェクトを使用して定義した後、サーバー データベース内 (およびサーバー データベースと同期する別のデータベース内) に作成します。完全なコンテキスト例でこのコードを表示するには、「方法: データベース同期を構成して実行する (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);

DbSyncTableDescription newTableDescription = new DbSyncTableDescription("Sales.NewTable");

DbSyncColumnDescription newTableIdCol = new DbSyncColumnDescription();
DbSyncColumnDescription newTableContentCol = new DbSyncColumnDescription();

newTableIdCol.UnquotedName = "NewTableId";
newTableIdCol.Type = "int";
newTableIdCol.IsPrimaryKey = true;

newTableContentCol.UnquotedName = "NewTableContent";
newTableContentCol.Type = "nvarchar";
newTableContentCol.Size = "100";
newTableContentCol.IsPrimaryKey = false;

newTableDescription.Columns.Add(newTableIdCol);
newTableDescription.Columns.Add(newTableContentCol);
scopeDesc.Tables.Add(newTableDescription);
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) 

Dim newTableDescription As New DbSyncTableDescription("Sales.NewTable")

Dim newTableIdCol As New DbSyncColumnDescription()
Dim newTableContentCol As New DbSyncColumnDescription()

newTableIdCol.UnquotedName = "NewTableId" 
newTableIdCol.Type = "int" 
newTableIdCol.IsPrimaryKey = True 

newTableContentCol.UnquotedName = "NewTableContent" 
newTableContentCol.Type = "nvarchar" 
newTableContentCol.Size = "100" 
newTableContentCol.IsPrimaryKey = False 

newTableDescription.Columns.Add(newTableIdCol) 
newTableDescription.Columns.Add(newTableContentCol) 
scopeDesc.Tables.Add(newTableDescription) 

継承階層

System. . :: . .Object
  Microsoft.Synchronization.Data..::..DbSyncTableDescription

スレッド セーフ

この型の public static (Visual Basic では Shared) のメンバーはスレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

参照

参照

DbSyncTableDescription メンバー

Microsoft.Synchronization.Data 名前空間