Table of Contents

Method RunCommand

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

RunCommand<TResult>(Command<TResult>, ReadPreference, CancellationToken)

Runs a command.

public virtual TResult RunCommand<TResult>(Command<TResult> command, ReadPreference readPreference = null, CancellationToken cancellationToken = default)

Parameters

command Command<TResult>

The command.

readPreference ReadPreference

The read preference.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The result of the command.

Type Parameters

TResult

The result type of the command.

RunCommand<TResult>(IClientSessionHandle, Command<TResult>, ReadPreference, CancellationToken)

Runs a command.

public virtual TResult RunCommand<TResult>(IClientSessionHandle session, Command<TResult> command, ReadPreference readPreference = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

command Command<TResult>

The command.

readPreference ReadPreference

The read preference.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The result of the command.

Type Parameters

TResult

The result type of the command.