Table of Contents

Method GetCollection

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Legacy.dll

GetCollection<TDefaultDocument>(string)

Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.

public virtual MongoCollection<TDefaultDocument> GetCollection<TDefaultDocument>(string collectionName)

Parameters

collectionName string

The name of the collection.

Returns

MongoCollection<TDefaultDocument>

An instance of MongoCollection.

Type Parameters

TDefaultDocument

The default document type for this collection.

GetCollection<TDefaultDocument>(string, MongoCollectionSettings)

Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.

public virtual MongoCollection<TDefaultDocument> GetCollection<TDefaultDocument>(string collectionName, MongoCollectionSettings collectionSettings)

Parameters

collectionName string

The name of the collection.

collectionSettings MongoCollectionSettings

The settings to use when accessing this collection.

Returns

MongoCollection<TDefaultDocument>

An instance of MongoCollection.

Type Parameters

TDefaultDocument

The default document type for this collection.

GetCollection<TDefaultDocument>(string, WriteConcern)

Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.

public virtual MongoCollection<TDefaultDocument> GetCollection<TDefaultDocument>(string collectionName, WriteConcern writeConcern)

Parameters

collectionName string

The name of the collection.

writeConcern WriteConcern

The write concern to use when accessing this collection.

Returns

MongoCollection<TDefaultDocument>

An instance of MongoCollection.

Type Parameters

TDefaultDocument

The default document type for this collection.

GetCollection(string)

Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.

public virtual MongoCollection<BsonDocument> GetCollection(string collectionName)

Parameters

collectionName string

The name of the collection.

Returns

MongoCollection<BsonDocument>

An instance of MongoCollection.

GetCollection(string, MongoCollectionSettings)

Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.

public virtual MongoCollection<BsonDocument> GetCollection(string collectionName, MongoCollectionSettings collectionSettings)

Parameters

collectionName string

The name of the collection.

collectionSettings MongoCollectionSettings

The settings to use when accessing this collection.

Returns

MongoCollection<BsonDocument>

An instance of MongoCollection.

GetCollection(string, WriteConcern)

Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.

public virtual MongoCollection<BsonDocument> GetCollection(string collectionName, WriteConcern writeConcern)

Parameters

collectionName string

The name of the collection.

writeConcern WriteConcern

The write concern to use when accessing this collection.

Returns

MongoCollection<BsonDocument>

An instance of MongoCollection.

GetCollection(Type, string)

Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.

public virtual MongoCollection GetCollection(Type defaultDocumentType, string collectionName)

Parameters

defaultDocumentType Type

The default document type.

collectionName string

The name of the collection.

Returns

MongoCollection

An instance of MongoCollection.

GetCollection(Type, string, MongoCollectionSettings)

Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.

public virtual MongoCollection GetCollection(Type defaultDocumentType, string collectionName, MongoCollectionSettings collectionSettings)

Parameters

defaultDocumentType Type

The default document type.

collectionName string

The name of the collection.

collectionSettings MongoCollectionSettings

The settings to use when accessing this collection.

Returns

MongoCollection

An instance of MongoCollection.

GetCollection(Type, string, WriteConcern)

Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.

public virtual MongoCollection GetCollection(Type defaultDocumentType, string collectionName, WriteConcern writeConcern)

Parameters

defaultDocumentType Type

The default document type.

collectionName string

The name of the collection.

writeConcern WriteConcern

The write concern to use when accessing this collection.

Returns

MongoCollection

An instance of MongoCollection.