Table of Contents

Method RunCommandAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

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

Runs a command.

Task<TResult> RunCommandAsync<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

Task<TResult>

The result of the command.

Type Parameters

TResult

The result type of the command.

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

Runs a command.

Task<TResult> RunCommandAsync<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

Task<TResult>

The result of the command.

Type Parameters

TResult

The result type of the command.