Share via


DbServerSyncProvider.SelectClientIdCommand Property

Gets or sets an IDbCommand object that contains the query or stored procedure that returns originator IDs from the server database.

Namespace: Microsoft.Synchronization.Data.Server
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)

Syntax

'Declaration
Public Property SelectClientIdCommand As IDbCommand
public IDbCommand SelectClientIdCommand { get; set; }
public:
property IDbCommand^ SelectClientIdCommand {
    IDbCommand^ get ();
    void set (IDbCommand^ value);
}
/** @property */
public IDbCommand get_SelectClientIdCommand ()

/** @property */
public void set_SelectClientIdCommand (IDbCommand value)
public function get SelectClientIdCommand () : IDbCommand

public function set SelectClientIdCommand (value : IDbCommand)

Property Value

An IDbCommand object that contains a query or stored procedure.

Remarks

By default, Synchronization Services identifies each client database with a GUID, which is exposed by the ClientId property. You can also map this GUID to an integer by using the SelectClientIdCommand. The mapped value is exposed by the OriginatorId property. The command is not required, but it can be useful to use an integer to represent a client instead of the GUID that Synchronization Services uses.

Example

The following code example specifies a command to map a client ID to an originator ID. The command uses a stored procedure on the server database to perform the mapping. To view this code in the context of a complete example, see How to: Use Session Variables.

SqlCommand selectClientIdCommand = new SqlCommand();
selectClientIdCommand.CommandType = CommandType.StoredProcedure;
selectClientIdCommand.CommandText = "usp_GetOriginatorId";
selectClientIdCommand.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
selectClientIdCommand.Parameters.Add("@" + SyncSession.SyncOriginatorId, SqlDbType.Int).Direction = ParameterDirection.Output;
selectClientIdCommand.Connection = serverConn;
this.SelectClientIdCommand = selectClientIdCommand;
Dim selectClientIdCommand As New SqlCommand()
With selectClientIdCommand
    .CommandType = CommandType.StoredProcedure
    .CommandText = "usp_GetOriginatorId"
    .Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier)
    .Parameters.Add("@" + SyncSession.SyncOriginatorId, SqlDbType.Int).Direction = ParameterDirection.Output
    .Connection = serverConn
End With
Me.SelectClientIdCommand = selectClientIdCommand

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements (Synchronization Services).

Target Platforms

See Also

Reference

DbServerSyncProvider Class
DbServerSyncProvider Members
Microsoft.Synchronization.Data.Server Namespace