Table of Contents

Method InsertOneAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

InsertOneAsync(TDocument, CancellationToken)

Inserts a single document.

[Obsolete("Use the new overload of InsertOneAsync with an InsertOneOptions parameter instead.")]
public virtual Task InsertOneAsync(TDocument document, CancellationToken _cancellationToken)

Parameters

document TDocument

The document.

_cancellationToken CancellationToken

The cancellation token.

Returns

Task

The result of the insert operation.

InsertOneAsync(TDocument, InsertOneOptions, CancellationToken)

Inserts a single document.

public virtual Task InsertOneAsync(TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default)

Parameters

document TDocument

The document.

options InsertOneOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

The result of the insert operation.

InsertOneAsync(IClientSessionHandle, TDocument, InsertOneOptions, CancellationToken)

Inserts a single document.

public virtual Task InsertOneAsync(IClientSessionHandle session, TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

document TDocument

The document.

options InsertOneOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

The result of the insert operation.