Table of Contents

Interface IChannel

Namespace
MongoDB.Driver.Core.Bindings
Assembly
MongoDB.Driver.Core.dll

Represents a channel (similar to a connection but operates at the level of protocols rather than messages).

public interface IChannel : IDisposable
Inherited Members

Properties

Connection

Gets the connection.

IConnectionHandle Connection { get; }

Property Value

IConnectionHandle

The connection.

ConnectionDescription

Gets the connection description.

ConnectionDescription ConnectionDescription { get; }

Property Value

ConnectionDescription

The connection description.

Methods

CommandAsync<TResult>(ICoreSession, ReadPreference, DatabaseNamespace, BsonDocument, IEnumerable<Type1CommandMessageSection>, IElementNameValidator, BsonDocument, Action<IMessageEncoderPostProcessor>, CommandResponseHandling, IBsonSerializer<TResult>, MessageEncoderSettings, CancellationToken)

Executes a Command protocol.

Task<TResult> CommandAsync<TResult>(ICoreSession session, ReadPreference readPreference, DatabaseNamespace databaseNamespace, BsonDocument command, IEnumerable<Type1CommandMessageSection> commandPayloads, IElementNameValidator commandValidator, BsonDocument additionalOptions, Action<IMessageEncoderPostProcessor> postWriteAction, CommandResponseHandling responseHandling, IBsonSerializer<TResult> resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

session ICoreSession

The session.

readPreference ReadPreference

The read preference.

databaseNamespace DatabaseNamespace

The database namespace.

command BsonDocument

The command.

commandPayloads IEnumerable<Type1CommandMessageSection>

The command payloads.

commandValidator IElementNameValidator

The command validator.

additionalOptions BsonDocument

The additional options.

postWriteAction Action<IMessageEncoderPostProcessor>

The post write action.

responseHandling CommandResponseHandling

The response handling.

resultSerializer IBsonSerializer<TResult>

The result serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TResult>

A Task whose result is the result of the Command protocol.

Type Parameters

TResult

The type of the result.

Command<TResult>(ICoreSession, ReadPreference, DatabaseNamespace, BsonDocument, IEnumerable<Type1CommandMessageSection>, IElementNameValidator, BsonDocument, Action<IMessageEncoderPostProcessor>, CommandResponseHandling, IBsonSerializer<TResult>, MessageEncoderSettings, CancellationToken)

Executes a Command protocol.

TResult Command<TResult>(ICoreSession session, ReadPreference readPreference, DatabaseNamespace databaseNamespace, BsonDocument command, IEnumerable<Type1CommandMessageSection> commandPayloads, IElementNameValidator commandValidator, BsonDocument additionalOptions, Action<IMessageEncoderPostProcessor> postWriteAction, CommandResponseHandling responseHandling, IBsonSerializer<TResult> resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

session ICoreSession

The session.

readPreference ReadPreference

The read preference.

databaseNamespace DatabaseNamespace

The database namespace.

command BsonDocument

The command.

commandPayloads IEnumerable<Type1CommandMessageSection>

The command payloads.

commandValidator IElementNameValidator

The command validator.

additionalOptions BsonDocument

The additional options.

postWriteAction Action<IMessageEncoderPostProcessor>

The post write action.

responseHandling CommandResponseHandling

The response handling.

resultSerializer IBsonSerializer<TResult>

The result serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The result of the Command protocol.

Type Parameters

TResult

The type of the result.

QueryAsync<TDocument>(CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, IBsonSerializer<TDocument>, MessageEncoderSettings, CancellationToken)

Executes a Query protocol.

Task<CursorBatch<TDocument>> QueryAsync<TDocument>(CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool tailableCursor, bool awaitData, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

fields BsonDocument

The fields.

queryValidator IElementNameValidator

The query validator.

skip int

The number of documents to skip.

batchSize int

The size of a batch.

secondaryOk bool

if set to true sets the SecondaryOk bit to true in the query message sent to the server.

partialOk bool

if set to true the server is allowed to return partial results if any shards are unavailable.

noCursorTimeout bool

if set to true the server will not timeout the cursor.

tailableCursor bool

if set to true the query should return a tailable cursor.

awaitData bool

if set to true the server should await awhile before returning an empty batch for a tailable cursor.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<CursorBatch<TDocument>>

A Task whose result is the result of the Insert protocol.

Type Parameters

TDocument

The type of the document.

QueryAsync<TDocument>(CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, bool, IBsonSerializer<TDocument>, MessageEncoderSettings, CancellationToken)

Executes a Query protocol.

[Obsolete("Use an overload that does not have an oplogReplay parameter instead.")]
Task<CursorBatch<TDocument>> QueryAsync<TDocument>(CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool oplogReplay, bool tailableCursor, bool awaitData, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

fields BsonDocument

The fields.

queryValidator IElementNameValidator

The query validator.

skip int

The number of documents to skip.

batchSize int

The size of a batch.

secondaryOk bool

if set to true sets the SecondaryOk bit to true in the query message sent to the server.

partialOk bool

if set to true the server is allowed to return partial results if any shards are unavailable.

noCursorTimeout bool

if set to true the server will not timeout the cursor.

oplogReplay bool

if set to true the OplogReplay bit will be set.

tailableCursor bool

if set to true the query should return a tailable cursor.

awaitData bool

if set to true the server should await awhile before returning an empty batch for a tailable cursor.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<CursorBatch<TDocument>>

A Task whose result is the result of the Insert protocol.

Type Parameters

TDocument

The type of the document.

Query<TDocument>(CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, IBsonSerializer<TDocument>, MessageEncoderSettings, CancellationToken)

Executes a Query protocol.

CursorBatch<TDocument> Query<TDocument>(CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool tailableCursor, bool awaitData, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

fields BsonDocument

The fields.

queryValidator IElementNameValidator

The query validator.

skip int

The number of documents to skip.

batchSize int

The size of a batch.

secondaryOk bool

if set to true sets the SecondaryOk bit to true in the query message sent to the server.

partialOk bool

if set to true the server is allowed to return partial results if any shards are unavailable.

noCursorTimeout bool

if set to true the server will not timeout the cursor.

tailableCursor bool

if set to true the query should return a tailable cursor.

awaitData bool

if set to true the server should await awhile before returning an empty batch for a tailable cursor.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

CursorBatch<TDocument>

The result of the Insert protocol.

Type Parameters

TDocument

The type of the document.

Query<TDocument>(CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, bool, IBsonSerializer<TDocument>, MessageEncoderSettings, CancellationToken)

Executes a Query protocol.

[Obsolete("Use an overload that does not have an oplogReplay parameter instead.")]
CursorBatch<TDocument> Query<TDocument>(CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool oplogReplay, bool tailableCursor, bool awaitData, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

fields BsonDocument

The fields.

queryValidator IElementNameValidator

The query validator.

skip int

The number of documents to skip.

batchSize int

The size of a batch.

secondaryOk bool

if set to true sets the SecondaryOk bit to true in the query message sent to the server.

partialOk bool

if set to true the server is allowed to return partial results if any shards are unavailable.

noCursorTimeout bool

if set to true the server will not timeout the cursor.

oplogReplay bool

if set to true the OplogReplay bit will be set.

tailableCursor bool

if set to true the query should return a tailable cursor.

awaitData bool

if set to true the server should await awhile before returning an empty batch for a tailable cursor.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

CursorBatch<TDocument>

The result of the Insert protocol.

Type Parameters

TDocument

The type of the document.