Share via


RelationalSyncProvider.ScopeName Property

Gets or sets the name of the scope to synchronize.

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

Syntax

'Declaration
Public Overridable Property ScopeName As String
    Get
    Set
'Usage
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)

Property Value

Type: System.String
The name of the scope, which is a set of objects to synchronize.

Exceptions

Exception Condition
ObjectDisposedException

This RelationalSyncProvider is disposed.

ArgumentNullException

value is null reference (Nothing in Visual Basic).

Remarks

For database synchronization, a scope is a set of tables. For more information about how scopes are used, see How to: Provision a Server Database for Collaborative Synchronization (Non-SQL Server) and How To: Execute Database Synchronization (SQL Server).

Examples

The following code example specifies the scope for a DbSyncProvider object in the SetupSyncProvider method that was created for this documentation. This method is used so that providers can be configured easily for multiple nodes. To view this code in the context of a complete example, see How to: Synchronize Other ADO.NET Compatable Databases.

SqlConnection peerConnection = new SqlConnection(peerConnString);
sampleProvider.Connection = peerConnection;
sampleProvider.ScopeName = "Sales";
Dim peerConnection As New SqlConnection(peerConnString)
sampleProvider.Connection = peerConnection
sampleProvider.ScopeName = "Sales"

The following code example specifies the scope for a SqlSyncProvider object by using the DbSyncScopeDescription object, rather than setting ScopeName directly. To view this code in the context of a complete example, see How To: Execute Database Synchronization (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)

See Also

Reference

RelationalSyncProvider Class

Microsoft.Synchronization.Data Namespace