Class MongoClientBase
Base class for implementors of IMongoClient.
public abstract class MongoClientBase : IMongoClient
- Inheritance
-
MongoClientBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
Cluster
Gets the cluster.
public abstract ICluster Cluster { get; }
Property Value
- ICluster
The cluster.
Settings
Gets the settings.
public abstract MongoClientSettings Settings { get; }
Property Value
Methods
DropDatabase(IClientSessionHandle, string, CancellationToken)
Drops the database with the specified name.
public virtual void DropDatabase(IClientSessionHandle session, string name, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
name
stringThe name of the database to drop.
cancellationToken
CancellationTokenThe cancellation token.
DropDatabase(string, CancellationToken)
Drops the database with the specified name.
public virtual void DropDatabase(string name, CancellationToken cancellationToken = default)
Parameters
name
stringThe name of the database to drop.
cancellationToken
CancellationTokenThe cancellation token.
DropDatabaseAsync(IClientSessionHandle, string, CancellationToken)
Drops the database with the specified name.
public virtual Task DropDatabaseAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
name
stringThe name of the database to drop.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A task.
DropDatabaseAsync(string, CancellationToken)
Drops the database with the specified name.
public abstract Task DropDatabaseAsync(string name, CancellationToken cancellationToken = default)
Parameters
name
stringThe name of the database to drop.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A task.
GetDatabase(string, MongoDatabaseSettings)
Gets a database.
public abstract IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
Parameters
name
stringThe name of the database.
settings
MongoDatabaseSettingsThe database settings.
Returns
- IMongoDatabase
An implementation of a database.
ListDatabaseNames(IClientSessionHandle, ListDatabaseNamesOptions, CancellationToken)
Returns the names of the databases on the server.
public virtual IAsyncCursor<string> ListDatabaseNames(IClientSessionHandle session, ListDatabaseNamesOptions options, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
options
ListDatabaseNamesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<string>
The database names.
ListDatabaseNames(IClientSessionHandle, CancellationToken)
Returns the names of the databases on the server.
public virtual IAsyncCursor<string> ListDatabaseNames(IClientSessionHandle session, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<string>
The database names.
ListDatabaseNames(ListDatabaseNamesOptions, CancellationToken)
Returns the names of the databases on the server.
public virtual IAsyncCursor<string> ListDatabaseNames(ListDatabaseNamesOptions options, CancellationToken cancellationToken = default)
Parameters
options
ListDatabaseNamesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<string>
The database names.
ListDatabaseNames(CancellationToken)
Returns the names of the databases on the server.
public virtual IAsyncCursor<string> ListDatabaseNames(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<string>
The database names.
ListDatabaseNamesAsync(IClientSessionHandle, ListDatabaseNamesOptions, CancellationToken)
Returns the names of the databases on the server.
public virtual Task<IAsyncCursor<string>> ListDatabaseNamesAsync(IClientSessionHandle session, ListDatabaseNamesOptions options, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
options
ListDatabaseNamesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<string>>
The database names.
ListDatabaseNamesAsync(IClientSessionHandle, CancellationToken)
Returns the names of the databases on the server.
public virtual Task<IAsyncCursor<string>> ListDatabaseNamesAsync(IClientSessionHandle session, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<string>>
The database names.
ListDatabaseNamesAsync(ListDatabaseNamesOptions, CancellationToken)
Returns the names of the databases on the server.
public virtual Task<IAsyncCursor<string>> ListDatabaseNamesAsync(ListDatabaseNamesOptions options, CancellationToken cancellationToken = default)
Parameters
options
ListDatabaseNamesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<string>>
The database names.
ListDatabaseNamesAsync(CancellationToken)
Returns the names of the databases on the server.
public virtual Task<IAsyncCursor<string>> ListDatabaseNamesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<string>>
The database names.
ListDatabases(IClientSessionHandle, ListDatabasesOptions, CancellationToken)
Lists the databases on the server.
public virtual IAsyncCursor<BsonDocument> ListDatabases(IClientSessionHandle session, ListDatabasesOptions options, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
options
ListDatabasesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<BsonDocument>
A cursor.
ListDatabases(IClientSessionHandle, CancellationToken)
Lists the databases on the server.
public virtual IAsyncCursor<BsonDocument> ListDatabases(IClientSessionHandle session, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<BsonDocument>
A cursor.
ListDatabases(ListDatabasesOptions, CancellationToken)
Lists the databases on the server.
public virtual IAsyncCursor<BsonDocument> ListDatabases(ListDatabasesOptions options, CancellationToken cancellationToken = default)
Parameters
options
ListDatabasesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<BsonDocument>
A cursor.
ListDatabases(CancellationToken)
Lists the databases on the server.
public virtual IAsyncCursor<BsonDocument> ListDatabases(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<BsonDocument>
A cursor.
ListDatabasesAsync(IClientSessionHandle, ListDatabasesOptions, CancellationToken)
Lists the databases on the server.
public virtual Task<IAsyncCursor<BsonDocument>> ListDatabasesAsync(IClientSessionHandle session, ListDatabasesOptions options, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
options
ListDatabasesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<BsonDocument>>
A Task whose result is a cursor.
ListDatabasesAsync(IClientSessionHandle, CancellationToken)
Lists the databases on the server.
public virtual Task<IAsyncCursor<BsonDocument>> ListDatabasesAsync(IClientSessionHandle session, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<BsonDocument>>
A Task whose result is a cursor.
ListDatabasesAsync(ListDatabasesOptions, CancellationToken)
Lists the databases on the server.
public virtual Task<IAsyncCursor<BsonDocument>> ListDatabasesAsync(ListDatabasesOptions options, CancellationToken cancellationToken = default)
Parameters
options
ListDatabasesOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<BsonDocument>>
A Task whose result is a cursor.
ListDatabasesAsync(CancellationToken)
Lists the databases on the server.
public abstract Task<IAsyncCursor<BsonDocument>> ListDatabasesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<BsonDocument>>
A Task whose result is a cursor.
StartSession(ClientSessionOptions, CancellationToken)
Starts a client session.
public virtual IClientSessionHandle StartSession(ClientSessionOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ClientSessionOptionsThe session options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IClientSessionHandle
A client session.
StartSessionAsync(ClientSessionOptions, CancellationToken)
Starts a client session.
public virtual Task<IClientSessionHandle> StartSessionAsync(ClientSessionOptions options = null, CancellationToken cancellationToken = default)
Parameters
options
ClientSessionOptionsThe session options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IClientSessionHandle>
A Task whose result is a client session.
WatchAsync<TResult>(IClientSessionHandle, PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)
Watches changes on all collections in all databases.
public virtual Task<IChangeStreamCursor<TResult>> WatchAsync<TResult>(IClientSessionHandle session, PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
pipeline
PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>The pipeline.
options
ChangeStreamOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IChangeStreamCursor<TResult>>
A change stream.
Type Parameters
TResult
The type of the result.
WatchAsync<TResult>(PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)
Watches changes on all collections in all databases.
public virtual Task<IChangeStreamCursor<TResult>> WatchAsync<TResult>(PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)
Parameters
pipeline
PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>The pipeline.
options
ChangeStreamOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IChangeStreamCursor<TResult>>
A change stream.
Type Parameters
TResult
The type of the result.
Watch<TResult>(IClientSessionHandle, PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)
Watches changes on all collections in all databases.
public virtual IChangeStreamCursor<TResult> Watch<TResult>(IClientSessionHandle session, PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
pipeline
PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>The pipeline.
options
ChangeStreamOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IChangeStreamCursor<TResult>
A change stream.
Type Parameters
TResult
The type of the result.
Watch<TResult>(PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>, ChangeStreamOptions, CancellationToken)
Watches changes on all collections in all databases.
public virtual IChangeStreamCursor<TResult> Watch<TResult>(PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)
Parameters
pipeline
PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult>The pipeline.
options
ChangeStreamOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IChangeStreamCursor<TResult>
A change stream.
Type Parameters
TResult
The type of the result.
WithReadConcern(ReadConcern)
Returns a new IMongoClient instance with a different read concern setting.
public virtual IMongoClient WithReadConcern(ReadConcern readConcern)
Parameters
readConcern
ReadConcernThe read concern.
Returns
- IMongoClient
A new IMongoClient instance with a different read concern setting.
WithReadPreference(ReadPreference)
Returns a new IMongoClient instance with a different read preference setting.
public virtual IMongoClient WithReadPreference(ReadPreference readPreference)
Parameters
readPreference
ReadPreferenceThe read preference.
Returns
- IMongoClient
A new IMongoClient instance with a different read preference setting.
WithWriteConcern(WriteConcern)
Returns a new IMongoClient instance with a different write concern setting.
public virtual IMongoClient WithWriteConcern(WriteConcern writeConcern)
Parameters
writeConcern
WriteConcernThe write concern.
Returns
- IMongoClient
A new IMongoClient instance with a different write concern setting.