共用方式為


ScopeName 屬性

取得或設定範圍的名稱。

命名空間:  Microsoft.Synchronization.Data
組件:  Microsoft.Synchronization.Data (在 Microsoft.Synchronization.Data.dll 中)

語法

'宣告
Public Property ScopeName As String
    Get
    Set
'用途
Dim instance As DbSyncScopeDescription
Dim value As String

value = instance.ScopeName

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

屬性值

型別:System. . :: . .String
範圍的名稱。

範例

下列程式碼範例會描述名為 filtered_customer 的範圍,並且新增三個資料表到此範圍:Customer、CustomerContact 和 NewTable。前兩個資料表已經在伺服器資料庫中,所以使用 GetDescriptionForTable 方法從伺服器資料庫擷取結構描述。雖然此範圍包含 Customer 資料表中的所有資料行,不過只包含 CustomerContact 資料表中的兩個資料行。NewTable 資料表是使用 DbSyncTableDescriptionDbSyncColumnDescription 物件定義,然後在伺服器資料庫 (以及要與它同步處理的資料庫) 中建立此資料表。若要在完整範例的內容中檢視這段程式碼,請參閱 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) 

請參閱

參考

DbSyncScopeDescription類別

DbSyncScopeDescription 成員

Microsoft.Synchronization.Data 命名空間