ScopeName 属性
获取或设置要同步的作用域的名称。
命名空间: Microsoft.Synchronization.Data
程序集: Microsoft.Synchronization.Data(在 Microsoft.Synchronization.Data.dll 中)
语法
声明
Public Overridable Property ScopeName As String
Get
Set
用法
Dim instance As RelationalSyncProvider
Dim value As String
value = instance.ScopeName
instance.ScopeName = value
public virtual string ScopeName { get; set; }
public:
virtual property String^ ScopeName {
String^ get ();
void set (String^ value);
}
abstract ScopeName : string with get, set
override ScopeName : string with get, set
function get ScopeName () : String
function set ScopeName (value : String)
属性值
类型:System. . :: . .String
作用域(一组要同步的对象)的名称。
异常
异常 | 条件 |
---|---|
ObjectDisposedException | 此 RelationalSyncProvider 已释放。 |
ArgumentNullException | value 为 null Nothing nullptr unit null 引用(在 Visual Basic 中为 Nothing) 。 |
注释
对于数据库同步,作用域是一组表。有关如何使用作用域的更多信息,请参见如何为协作同步设置服务器数据库(非 SQL Server) 和如何配置和执行数据库同步 (SQL Server)。
示例
以下代码示例针对已为此文档创建的 SetupSyncProvider 方法中的 DbSyncProvider 对象指定作用域。之所以使用此方法,目的是能够轻松地为多个节点配置提供程序。若要在完整示例上下文中查看此代码,请参见如何配置和执行协作同步(非 SQL Server)。
SqlConnection peerConnection = new SqlConnection(peerConnString);
sampleProvider.Connection = peerConnection;
sampleProvider.ScopeName = "Sales";
Dim peerConnection As New SqlConnection(peerConnString)
sampleProvider.Connection = peerConnection
sampleProvider.ScopeName = "Sales"
下面的代码示例通过使用 DbSyncScopeDescription 对象而非直接设置 ScopeName,为 SqlSyncProvider 对象指定作用域。若要在完整示例上下文中查看此代码,请参见如何配置和执行数据库同步 (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)