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 的範圍,並且新增三個資料表到此範圍:Customer、CustomerContact 和 NewTable。前兩個資料表已經在伺服器資料庫中,所以使用 GetDescriptionForTable 方法從伺服器資料庫擷取結構描述。雖然此範圍包含 Customer 資料表中的所有資料行,不過只包含 CustomerContact 資料表中的兩個資料行。NewTable 資料表是使用 DbSyncTableDescription 和 DbSyncColumnDescription 物件定義,然後在伺服器資料庫 (以及要與它同步處理的資料庫) 中建立此資料表。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:設定及執行資料庫同步處理 (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
執行緒安全性
這個類型的任何公用static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員都可以是安全執行緒。