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
'Usage
Dim instance As DbServerSyncProvider
Dim value As IDbCommand

value = instance.SelectClientIdCommand

instance.SelectClientIdCommand = value
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, Sync Framework 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 Sync Framework 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

See Also

Reference

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