RelationalSyncProvider.ScopeName 属性
获取或设置要同步的作用域的名称。
此属性不符合 CLS。
命名空间: Microsoft.Synchronization.Data
程序集: Microsoft.Synchronization.Data(在 microsoft.synchronization.data.dll 中)
语法
声明
Public Overridable Property ScopeName As String
用法
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);
}
/** @property */
public String get_ScopeName ()
/** @property */
public void set_ScopeName (String value)
public function get ScopeName () : String
public function set ScopeName (value : String)
属性值
作用域(一组要同步的对象)的名称。
备注
对于数据库同步,作用域是一组表。有关如何使用作用域的更多信息,请参见如何为协作同步设置服务器数据库(非 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)
请参阅
参考
RelationalSyncProvider 类
RelationalSyncProvider 成员
Microsoft.Synchronization.Data 命名空间