Table of Contents

Class MongoClient

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

public sealed class MongoClient : IMongoClient, IDisposable
Inheritance
MongoClient
Implements
Inherited Members
Extension Methods

Constructors

MongoClient()

Initializes a new instance of the MongoClient class.

MongoClient(MongoClientSettings)

Initializes a new instance of the MongoClient class.

MongoClient(MongoUrl)

Initializes a new instance of the MongoClient class.

MongoClient(string)

Initializes a new instance of the MongoClient class.

Properties

Cluster

Gets the cluster.

Settings

Gets the settings.

Methods

BulkWrite(IClientSessionHandle, IReadOnlyList<BulkWriteModel>, ClientBulkWriteOptions, CancellationToken)

Executes a list of mixed write operations.

BulkWrite(IReadOnlyList<BulkWriteModel>, ClientBulkWriteOptions, CancellationToken)

Executes a list of mixed write operations.

BulkWriteAsync(IClientSessionHandle, IReadOnlyList<BulkWriteModel>, ClientBulkWriteOptions, CancellationToken)

Executes a list of mixed write operations.

BulkWriteAsync(IReadOnlyList<BulkWriteModel>, ClientBulkWriteOptions, CancellationToken)

Executes a list of mixed write operations.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

DropDatabase(IClientSessionHandle, string, CancellationToken)

Drops the database with the specified name.

DropDatabase(string, CancellationToken)

Drops the database with the specified name.

DropDatabaseAsync(IClientSessionHandle, string, CancellationToken)

Drops the database with the specified name.

DropDatabaseAsync(string, CancellationToken)

Drops the database with the specified name.

GetDatabase(string, MongoDatabaseSettings)

Gets a database.

ListDatabaseNames(IClientSessionHandle, ListDatabaseNamesOptions, CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNames(IClientSessionHandle, CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNames(ListDatabaseNamesOptions, CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNames(CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNamesAsync(IClientSessionHandle, ListDatabaseNamesOptions, CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNamesAsync(IClientSessionHandle, CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNamesAsync(ListDatabaseNamesOptions, CancellationToken)

Returns the names of the databases on the server.

ListDatabaseNamesAsync(CancellationToken)

Returns the names of the databases on the server.

ListDatabases(IClientSessionHandle, ListDatabasesOptions, CancellationToken)

Lists the databases on the server.

ListDatabases(IClientSessionHandle, CancellationToken)

Lists the databases on the server.

ListDatabases(ListDatabasesOptions, CancellationToken)

Lists the databases on the server.

ListDatabases(CancellationToken)

Lists the databases on the server.

ListDatabasesAsync(IClientSessionHandle, ListDatabasesOptions, CancellationToken)

Lists the databases on the server.

ListDatabasesAsync(IClientSessionHandle, CancellationToken)

Lists the databases on the server.

ListDatabasesAsync(ListDatabasesOptions, CancellationToken)

Lists the databases on the server.

ListDatabasesAsync(CancellationToken)

Lists the databases on the server.

StartSession(ClientSessionOptions, CancellationToken)

Starts a client session.

StartSessionAsync(ClientSessionOptions, CancellationToken)

Starts a client session.

WatchAsync<TResult>(IClientSessionHandle, PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on all collections in all databases.

WatchAsync<TResult>(PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on all collections in all databases.

Watch<TResult>(IClientSessionHandle, PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on all collections in all databases.

Watch<TResult>(PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on all collections in all databases.

WithReadConcern(ReadConcern)

Returns a new IMongoClient instance with a different read concern setting.

WithReadPreference(ReadPreference)

Returns a new IMongoClient instance with a different read preference setting.

WithWriteConcern(WriteConcern)

Returns a new IMongoClient instance with a different write concern setting.