Table of Contents

Namespace MongoDB.Driver

The MongoDB.Driver namespace contains all the basic types and classes that compose the MongoDB driver. It contains the classes needed for most interactions with the database.

Classes

AggregateBucketAutoOptions

Represents options for the BucketAuto method.

AggregateBucketAutoResultIdSerializer

Static factory class for AggregateBucketAutoResultIdSerializer.

AggregateBucketAutoResultIdSerializer<TValue>

A serializer for AggregateBucketAutoResultId.

AggregateBucketAutoResultId<TValue>

Represents the _id value in the result of a $bucketAuto stage.

AggregateBucketAutoResult<TValue>

Represents the result of the $bucketAuto stage.

AggregateBucketOptions<TValue>

Represents options for the Bucket method.

AggregateBucketResult<TValue>

Represents the result of the $bucket stage.

AggregateCountResult

Result type for the aggregate $count stage.

AggregateExpressionDefinition<TSource, TResult>

An aggregation expression.

AggregateFacet

Represents static methods for creating facets.

AggregateFacetOptions<TOutput>

Options for the aggregate $facet stage.

AggregateFacetResult

Represents an abstract AggregateFacetResult with an arbitrary TOutput type.

AggregateFacetResult<TOutput>

Represents the result of a single facet.

AggregateFacetResults

Represents the results of a $facet stage with an arbitrary number of facets.

AggregateFacet<TInput>

Represents a facet to be passed to the Facet method.

AggregateFacet<TInput, TOutput>

Represents a facet to be passed to the Facet method.

AggregateFluentBase<TResult>

Base class for implementors of IAggregateFluent<TResult>.

AggregateGraphLookupOptions<TFrom, TAsElement, TOutput>

Represents options for the GraphLookup method.

AggregateLookupOptions<TForeignDocument, TResult>

Options for the aggregate $lookup stage.

AggregateOptions

Options for an aggregate operation.

AggregateSortByCountResult<TId>

Result type for the aggregate $sortByCount stage.

AggregateUnwindOptions<TResult>

Options for the $unwind aggregation stage.

AppendedStagePipelineDefinition<TInput, TIntermediate, TOutput>

Represents a pipeline consisting of an existing pipeline with one additional stage appended.

ArrayFilterDefinition

Base class for array filters.

ArrayFilterDefinition<TItem>

Base class for array filters.

BatchTransformingAsyncCursor<TFromDocument, TToDocument>

Represents a cursor that wraps another cursor with a transformation function on the documents.

BsonDocumentArrayFilterDefinition<TItem>

A BsonDocument based array filter.

BsonDocumentCommand<TResult>

A BsonDocument based command.

BsonDocumentFilterDefinition<TDocument>

A BsonDocument based filter.

BsonDocumentIndexKeysDefinition<TDocument>

A BsonDocument based index keys definition.

BsonDocumentPipelineStageDefinition<TInput, TOutput>

A BsonDocument based stage.

BsonDocumentProjectionDefinition<TSource>

A BsonDocument based projection whose projection type is not yet known.

BsonDocumentProjectionDefinition<TSource, TProjection>

A BsonDocument based projection.

BsonDocumentSortDefinition<TDocument>

A BsonDocument based sort.

BsonDocumentStagePipelineDefinition<TInput, TOutput>

A pipeline composed of instances of BsonDocument.

BsonDocumentUpdateDefinition<TDocument>

A BsonDocument based update.

BsonValueAggregateExpressionDefinition<TSource, TResult>

A BsonValue based aggregate expression.

Builders<TDocument>

A static helper class containing various builders.

BulkWriteError

Represents the details of a write error for a particular request.

BulkWriteOptions

Options for a bulk write operation.

BulkWriteResult

Represents the result of a bulk write operation.

BulkWriteResult<TDocument>

Represents the result of a bulk write operation.

BulkWriteResult<TDocument>.Acknowledged

Result from an acknowledged write concern.

BulkWriteResult<TDocument>.Unacknowledged

Result from an unacknowledged write concern.

BulkWriteUpsert

Represents the information about one Upsert.

ChangeStreamDocumentSerializer<TDocument>

A serializer for ChangeStreamDocument instances.

ChangeStreamDocument<TDocument>

An output document from a $changeStream pipeline stage.

ChangeStreamOperationTypeSerializer

A serializer for ChangeStreamOperationType values.

ChangeStreamOptions

Options for a change stream operation.

ChangeStreamPreAndPostImagesOptions

Change stream pre and post images options.

ChangeStreamSplitEvent

Change stream splitEvent data.

ChangeStreamStageOptions

Options for a $changeStream stage.

ChangeStreamUpdateDescription

An UpdateDescription in a ChangeStreamDocument instance.

ChangeStreamUpdateDescriptionSerializer

A serialize for ChangeStreamUpdateDescription values.

ClientSessionOptions

Client session options.

ClientSideDeserializationProjectionDefinition<TSource, TProjection>

A client side only projection that is implemented solely by deserializing using a different serializer.

ClusterRegistry

Represents a registry of already created clusters.

ClusteredIndexOptions<TDocument>

Options for creating a clustered index.

Collation

Represents a MongoDB collation.

CollectionNamespace

Represents a collection namespace.

Command<TResult>

Base class for commands.

ConstantSetFieldDefinition<TDocument, TField>

A SetFieldDefinition that uses a field and a a constant to define the field to be set.

CountOptions

Options for a count operation.

CreateCollectionOptions

Options for creating a collection.

CreateCollectionOptions<TDocument>

Options for creating a collection.

CreateIndexCommitQuorum

Represents a create index commit quorum.

CreateIndexCommitQuorumWithMode

Represents a CreateIndexCommitQuorum with a mode value.

CreateIndexCommitQuorumWithW

Represents a CreateIndexCommitQuorum with a w value.

CreateIndexModel<TDocument>

Model for creating an index.

CreateIndexOptions

Options for creating an index.

CreateIndexOptions<TDocument>

Options for creating an index.

CreateManyIndexesOptions

Options for creating multiple indexes.

CreateOneIndexOptions

Options for creating a single index.

CreateSearchIndexModel

Model for creating a search index.

CreateViewOptions<TDocument>

Options for creating a view.

DatabaseNamespace

Represents a database namespace.

DeferredAsyncCursor<TDocument>

Represents a cursor for an operation that is not actually executed until MoveNextAsync is called for the first time.

DeleteManyModel<TDocument>

Model for deleting many documents.

DeleteOneModel<TDocument>

Model for deleting a single document.

DeleteOptions

Options for the Delete methods.

DeleteResult

The result of a delete operation.

DeleteResult.Acknowledged

The result of an acknowledged delete operation.

DeleteResult.Unacknowledged

The result of an unacknowledged delete operation.

DensifyBounds

Represents keyword densify bounds.

DensifyDateTimeBounds

Represents a DateTime densify bounds.

DensifyDateTimeRange

Represents a DateTime densify range.

DensifyKeywordDateTimeBounds

Represents a keyword DateTime densify bounds.

DensifyKeywordNumericBounds<TNumber>

Represents a keyword numeric densify bounds.

DensifyLowerUpperDateTimeBounds

Represents a DateTime densify bounds with lower and upper bounds.

DensifyLowerUpperNumericBounds<TNumber>

Represents a numeric densify bounds with lower and upper bounds.

DensifyNumericBounds<TNumber>

Represents a numeric densify bounds.

DensifyNumericRange<TNumber>

Represents a numeric densify range.

DensifyRange

Represents a range for the $densify stage.

DistinctOptions

Options for the distinct command.

DocumentsAggregateExpressionDefinition<TDocument>

An aggregate expression for the $documents stage.

DocumentsWindow

Represents a documents window for a SetWindowFields window method.

DocumentsWindowBoundary

Represents a boundary for a documents window in SetWindowFields.

DropCollectionOptions

Options for dropping a collection.

DropIndexOptions

Options for dropping an index.

EmptyPipelineDefinition<TInput>

Represents an empty pipeline.

EstimatedDocumentCountOptions

Options for estimated document count.

ExpressionAggregateExpressionDefinition<TSource, TResult>

A BsonValue based aggregate expression.

ExpressionFieldDefinition<TDocument>

An Expression based field.

ExpressionFieldDefinition<TDocument, TField>

An Expression based field.

ExpressionFilterDefinition<TDocument>

An Expression based filter.

ExpressionSetFieldDefinitions<TDocument, TFields>

A subclass of SetFieldDefinition that uses an Expression to define the fields to be set.

ExpressionTranslationOptions

Options for controlling translation from .NET expression trees into MongoDB expressions.

ExternalEvidence

Evidence of a MongoIdentity via an external mechanism. For example, on windows this may be the current process' user or, on linux, via kinit.

FieldDefinition<TDocument>

Base class for field names.

FieldDefinition<TDocument, TField>

Base class for field names.

FilterDefinitionBuilder<TDocument>

A builder for a FilterDefinition<TDocument>.

FilterDefinition<TDocument>

Base class for filters.

FindExpressionProjectionDefinition<TSource, TProjection>

A find Expression based projection.

FindFluentBase<TDocument, TProjection>

Base class for implementors of IFindFluent<TDocument, TProjection>.

FindOneAndDeleteOptions<TDocument>

Options for a findAndModify command to delete an object.

FindOneAndDeleteOptions<TDocument, TProjection>

Options for a findAndModify command to delete an object.

FindOneAndReplaceOptions<TDocument>

Options for a findAndModify command to replace an object.

FindOneAndReplaceOptions<TDocument, TProjection>

Options for a findAndModify command to replace an object.

FindOneAndUpdateOptions<TDocument>

Options for a findAndModify command to update an object.

FindOneAndUpdateOptions<TDocument, TProjection>

Options for a findAndModify command to update an object.

FindOptions

Options for finding documents.

FindOptionsBase

Options for a find operation.

FindOptions<TDocument>

Options for finding documents.

FindOptions<TDocument, TProjection>

Options for finding documents.

IAggregateFluentExtensions

Extension methods for IAggregateFluent<TResult>

IAsyncCursorExtensions

Represents extension methods for IAsyncCursor.

IAsyncCursorSourceExtensions

Represents extension methods for IAsyncCursorSource.

IFindFluentExtensions

Extension methods for IFindFluent<TDocument, TProjection>

IMongoClientExtensions

Extension methods on IMongoClient.

IMongoCollectionExtensions

Extension methods for IMongoCollection<TDocument>.

IMongoDatabaseExtensions

Extension methods on IMongoDatabase.

ISetWindowFieldsPartition<TInput>

Represents a partition for SetWindowFields.

IndexKeysDefinitionBuilder<TDocument>

A builder for an IndexKeysDefinition<TDocument>.

IndexKeysDefinitionExtensions

Extension methods for an index keys definition.

IndexKeysDefinition<TDocument>

Base class for an index keys definition.

IndexOptionDefaults

Represents index option defaults.

InsertManyOptions

Options for inserting many documents.

InsertOneModel<TDocument>

Model for inserting a single document.

InsertOneOptions

Options for inserting one document.

JsonArrayFilterDefinition<TItem>

A JSON string based array filter.

JsonCommand<TResult>

A JSON string based command.

JsonFilterDefinition<TDocument>

A JSON string based filter.

JsonIndexKeysDefinition<TDocument>

A JSON string based index keys definition.

JsonPipelineStageDefinition<TInput, TOutput>

A JSON string based pipeline stage.

JsonProjectionDefinition<TSource>

A JSON string based projection whose projection type is not yet known.

JsonProjectionDefinition<TSource, TProjection>

A JSON string based projection.

JsonSortDefinition<TDocument>

A JSON string based sort.

JsonUpdateDefinition<TDocument>

A JSON string based update.

KeywordDocumentsWindowBoundary

Represents a keyword boundary for a document window in SetWindowFields (i.e. "unbounded" or "current").

KeywordRangeWindowBoundary

Represents a keyword boundary for a range window in SetWindowFields (i.e. "unbounded" or "current").

ListCollectionNamesOptions

Options for a list collection names operation.

ListCollectionsOptions

Options for a list collections operation.

ListDatabaseNamesOptions

Options for a list database names operation.

ListDatabasesOptions

Options for a list databases operation.

ListIndexesOptions

Options for a list indexes operation.

ListSetFieldDefinitionsExtensions

Extension methods to add additional set field definitions to an existing instance of ListSetFieldDefinitions.

ListSetFieldDefinitions<TDocument>

A subclass of SetFieldDefinitions containing a list of SetFieldDefinition instances to define the fields to be set.

MapReduceOptions<TDocument, TResult>

Represents the options for a map-reduce operation.

MapReduceOutputOptions

Represents the output options for a map-reduce operation.

MergeStageOptions<TOutput>

Options for the $merge aggregation pipeline stage.

MongoAuthenticationException

Represents a MongoDB authentication exception.

MongoBulkWriteException

Represents a bulk write exception.

MongoBulkWriteException<TDocument>

Represents a bulk write exception.

MongoClient

Base class for implementors of IMongoClient.

MongoClientBase

Base class for implementors of IMongoClient.

MongoClientException

Represents a MongoDB client exception.

MongoClientSettings

The settings for a MongoDB client.

MongoCollectionBase<TDocument>

Base class for implementors of IMongoCollection<TDocument>.

MongoCollectionSettings

The settings used to access a collection.

MongoCommandException

Represents a MongoDB command exception.

MongoConfigurationException

Represents a MongoDB configuration exception.

MongoConnectionClosedException

Represents a MongoDB connection failed exception.

MongoConnectionException

Represents a MongoDB connection exception.

MongoConnectionPoolPausedException

Represents a MongoDB connection pool paused exception.

MongoCredential

Credential to access a MongoDB database.

MongoCursorNotFoundException

Represents a MongoDB cursor not found exception.

MongoDBRef

Represents a DBRef (a convenient way to refer to a document).

MongoDBRefSerializer

Represents a serializer for MongoDBRefs.

MongoDatabaseBase

Base class for implementors of IMongoDatabase.

MongoDatabaseSettings

The settings used to access a database.

MongoDefaults

Default values for various Mongo settings.

MongoDuplicateKeyException

Represents a MongoDB duplicate key exception.

MongoException

Represents a MongoDB exception.

MongoExecutionTimeoutException

Represents a MongoDB execution timeout exception.

MongoExternalAwsIdentity

Represents an identity defined by AWS external credentials.

MongoExternalIdentity

Represents an identity defined outside of mongodb.

MongoIdentity

Represents an identity in MongoDB.

MongoIdentityEvidence

Evidence used as proof of a MongoIdentity.

MongoIncompatibleDriverException

Represents a MongoDB incompatible driver exception.

MongoIndexManagerBase<TDocument>

Base class for implementors of IMongoIndexManager<TDocument>.

MongoInternalException

Represents a MongoDB internal exception (almost surely the result of a bug).

MongoInternalIdentity

Represents an identity defined inside mongodb.

MongoNodeIsRecoveringException

Represents a MongoDB node is recovering exception.

MongoNotPrimaryException

Represents a MongoDB not primary exception.

MongoOidcIdentity

Represents an OIDC identity.

MongoQueryException

Represents a MongoDB query exception.

MongoServerAddress

The address of a MongoDB server.

MongoServerException

Represents a MongoDB server exception.

MongoUrl

Represents an immutable URL style connection string. See also MongoUrlBuilder.

MongoUrlBuilder

Represents URL-style connection strings.

MongoUrlTypeConverter

Implements a TypeConverter for converting MongoUrl.

MongoUtils

Various static utility methods.

MongoWaitQueueFullException

Represents a MongoDB connection pool wait queue full exception.

MongoWriteConcernException

Represents a MongoDB write concern exception.

MongoWriteException

Represents a write exception.

MongoX509Identity

Represents an identity defined by an X509 certificate.

Mql

Contains methods that can be used to access MongoDB specific functionality in LINQ queries.

NoPipelineInput

Represents the void input data type to a pipeline with no input, such as a database aggregation. No actual instances of this type can be created.

ObjectCommand<TResult>

An Object based command.

ObjectFilterDefinition<TDocument>

An Object based filter.

ObjectProjectionDefinition<TSource>

An Object based projection whose projection type is not yet known.

ObjectProjectionDefinition<TSource, TProjection>

An Object based projection.

ObjectSortDefinition<TDocument>

An Object based sort.

ObjectUpdateDefinition<TDocument>

An Object based update.

Optional

Represents helper methods for use with the Optional<T> struct.

PasswordEvidence

Evidence of a MongoIdentity via a shared secret.

PipelineDefinitionBuilder

Extension methods for adding stages to a pipeline.

PipelineDefinition<TInput, TOutput>

Base class for a pipeline.

PipelineStageDefinitionBuilder

Methods for building pipeline stages.

PipelineStageDefinition<TInput, TOutput>

Base class for pipeline stages.

PipelineStagePipelineDefinition<TInput, TOutput>

A pipeline composed of instances of IPipelineStageDefinition.

PipelineUpdateDefinition<TDocument>

A PipelineDefinition<TInput, TOutput> based update definition.

PositionDocumentsWindowBoundary

Represents a position boundary for a document window in SetWindowFields.

PrependedStagePipelineDefinition<TInput, TIntermediate, TOutput>

Represents a pipeline consisting of an existing pipeline with one additional stage prepended.

ProjectionDefinitionBuilder<TSource>

A builder for a projection.

ProjectionDefinitionExtensions

Extension methods for projections.

ProjectionDefinition<TSource>

Base class for projections whose projection type is not yet known.

ProjectionDefinition<TSource, TProjection>

Base class for projections.

QueryVector

Vector search query vector.

RangeWindow

Represents a range window for a SetWindowFields window method.

RangeWindowBoundary

Represents a boundary for a range window in SetWindowFields.

ReadConcern

Represents a read concern.

ReadPreference

Represents a read preference.

ReadPreferenceHedge

Represents a read preference hedge.

RenameCollectionOptions

Options for renaming a collection.

RenderedCommand<TResult>

A rendered command.

RenderedFieldDefinition

A rendered field.

RenderedFieldDefinition<TField>

A rendered field.

RenderedPipelineDefinition<TOutput>

A rendered pipeline.

RenderedPipelineStageDefinition<TOutput>

A rendered pipeline stage.

RenderedProjectionDefinition<TProjection>

A rendered projection.

ReplaceOneModel<TDocument>

Model for replacing a single document.

ReplaceOneResult

The result of an update operation.

ReplaceOneResult.Acknowledged

The result of an acknowledged update operation.

ReplaceOneResult.Unacknowledged

The result of an unacknowledged update operation.

ReplaceOptions

Options for replacing a single document.

ReplaceOutputSerializerPipelineDefinition<TInput, TIntermediate, TOutput>

Represents a pipeline with the output serializer replaced.

ServerApi

Represents a server API.

ServerApiVersion

Represents a server API version.

SetFieldDefinition<TDocument>

A definition of a single field to be set.

SetFieldDefinitionsBuilder<TDocument>

A builder for SetFieldDefinitions.

SetFieldDefinitions<TDocument>

Defines the fields to be set by a $set stage.

SetWindowFieldsWindow

Represents a window for a SetWindowFields window method.

SortDefinitionBuilder<TDocument>

A builder for a SortDefinition<TDocument>.

SortDefinitionExtensions

Extension methods for SortDefinition.

SortDefinition<TDocument>

Base class for sorts.

SslSettings

Represents the settings for using SSL.

StringFieldDefinition<TDocument>

A string based field name.

StringFieldDefinition<TDocument, TField>

A string based field name.

StringOrRegularExpression

Represents a value that is either a string or a BsonRegularExpression.

Tag

Represents a replica set member tag.

TagSet

Represents a replica set member tag set.

TextSearchOptions

Represents text search options.

TimeRangeWindowBoundary

Represents a time boundary for a range window in SetWindowFields.

TimeSeriesOptions

Defines the time series options to use when creating a time series collection. See https://www.mongodb.com/docs/manual/reference/command/create/ for supported options and https://www.mongodb.com/docs/manual/core/timeseries-collections/ for more information on time series collections.

TransactionOptions

Transaction options.

UpdateDefinitionBuilder<TDocument>

A builder for an UpdateDefinition<TDocument>.

UpdateDefinitionExtensions

Extension methods for UpdateDefinition.

UpdateDefinition<TDocument>

Base class for updates.

UpdateManyModel<TDocument>

Model for updating many documents.

UpdateOneModel<TDocument>

Model for updating a single document.

UpdateOptions

Options for updating a single document.

UpdateResult

The result of an update operation.

UpdateResult.Acknowledged

The result of an acknowledged update operation.

UpdateResult.Unacknowledged

The result of an acknowledged update operation.

ValueRangeWindowBoundary

Represents a value boundary for a document window in SetWindowFields.

ValueRangeWindowBoundary<TValue>

Represents a value boundary for a range window in SetWindowFields.

VectorSearchOptions<TDocument>

Vector search options.

WriteConcern

Represents a write concern.

WriteConcern.WCount

Represents a numeric WValue.

WriteConcern.WMode

Represents a mode string WValue.

WriteConcern.WValue

Represents the base class for w values.

WriteConcernError

Represents the details of a write concern error.

WriteConcernResult

Represents the results of an operation performed with an acknowledged WriteConcern.

WriteError

Represents the details of a write error.

WriteModel<TDocument>

Base class for a write model.

Structs

AggregateBucketAutoGranularity

Represents the granularity value for a $bucketAuto stage.

Optional<T>

Represents an optional parameter that might or might not have a value.

PathRenderArgs

Encapsulates settings needed for path rendering.

RenderArgs<TDocument>

Encapsulates settings needed for rendering Builder definitions.

Setting<T>

Represents a setting that may or may not have been set.

Interfaces

IAggregateFluent<TResult>

Fluent interface for aggregate.

IAsyncCursorSource<TDocument>

Represents an operation that will return a cursor when executed.

IAsyncCursor<TDocument>

Represents an asynchronous cursor.

IChangeStreamCursor<TDocument>

Represents an asynchronous cursor for change stream.

IClientSession

The interface for a client session.

IClientSessionHandle

A handle to an underlying reference counted IClientSession.

ICoreServerSession

The interface for a core server session.

IFilteredMongoCollection<TDocument>

A filtered mongo collection. The filter will be and'ed with all filters.

IFindFluent<TDocument, TProjection>

Fluent interface for find.

IMongoClient

The client interface to MongoDB.

IMongoCollection<TDocument>

Represents a typed collection in MongoDB.

IMongoDatabase

Represents a database in MongoDB.

IMongoIndexManager<TDocument>

An interface representing methods used to create, delete and modify indexes.

IOrderedAggregateFluent<TResult>

Fluent interface for aggregate.

IOrderedFindFluent<TDocument, TProjection>

Fluent interface for find.

IPipelineStageDefinition

A pipeline stage.

IRenderedPipelineStageDefinition

A rendered pipeline stage.

IServerSession

The interface for a server session.

Enums

AggregateStringTranslationMode

Option for which expression to generate for certain string operations.

ChangeStreamFullDocumentBeforeChangeOption

Change stream FullDocumentBeforeChange option.

ChangeStreamFullDocumentOption

Change stream FullDocument option.

ChangeStreamOperationType

The operation type of a change stream result.

CollationAlternate

Controls whether spaces and punctuation are considered base characters.

CollationCaseFirst

Uppercase or lowercase first.

CollationMaxVariable

Controls which characters are affected by alternate: "Shifted".

CollationStrength

Prioritizes the comparison properties.

ConnectionMode

Server connection mode.

CursorType

The cursor type.

DensifyDateTimeUnit

Represents a densify DateTime unit.

DocumentValidationAction

Represents the document validation action.

DocumentValidationLevel

Represents the document validation level.

MergeStageWhenMatched

The behavior of $merge is a result document and an existing document in the collection have the same value for the specified on field(s).

MergeStageWhenNotMatched

The behavior of $merge if a result document does not match an existing document in the output collection.

ReadConcernLevel

The level of the read concern.

ReadPreferenceMode

Represents the read preference mode.

ReturnDocument

Which version of the document to return when executing a FindAndModify command.

ServerErrorCategory

Represents the category for an error from the server.

SortDirection

The direction of the sort.

TimeSeriesGranularity

Specifies the granularity of time series collection bucketing.

UpdateDefinitionCurrentDateType

The type to use for a $currentDate operator.

WriteModelType

The type of a write model.