Table of Contents

Class CollectionOptionsBuilder

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

A builder for the options used when creating a collection.

[Serializable]
[BsonSerializer(typeof(CollectionOptionsBuilder.Serializer))]
public class CollectionOptionsBuilder : BuilderBase, IConvertibleToBsonDocument, IMongoCollectionOptions
Inheritance
CollectionOptionsBuilder
Implements
Inherited Members
Extension Methods

Constructors

CollectionOptionsBuilder()

Initializes a new instance of the CollectionOptionsBuilder class.

public CollectionOptionsBuilder()

Methods

SetAutoIndexId(bool)

Sets whether to automatically create an index on the _id element.

[Obsolete("AutoIndexId has been deprecated since server version 3.2.")]
public CollectionOptionsBuilder SetAutoIndexId(bool value)

Parameters

value bool

Whether to automatically create an index on the _id element.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetCapped(bool)

Sets whether the collection is capped.

public CollectionOptionsBuilder SetCapped(bool value)

Parameters

value bool

Whether the collection is capped.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetCollation(Collation)

Sets the collation.

public CollectionOptionsBuilder SetCollation(Collation value)

Parameters

value Collation

The collation.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetIndexOptionDefaults(IndexOptionDefaults)

Sets the index options defaults.

public CollectionOptionsBuilder SetIndexOptionDefaults(IndexOptionDefaults value)

Parameters

value IndexOptionDefaults

The index options defaults.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetMaxDocuments(long)

Sets the max number of documents in a capped collection.

public CollectionOptionsBuilder SetMaxDocuments(long value)

Parameters

value long

The max number of documents.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetMaxSize(long)

Sets the max size of a capped collection.

public CollectionOptionsBuilder SetMaxSize(long value)

Parameters

value long

The max size.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetStorageEngineOptions(BsonDocument)

Sets the storage engine options.

public CollectionOptionsBuilder SetStorageEngineOptions(BsonDocument value)

Parameters

value BsonDocument

The value.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetValidationAction(DocumentValidationAction)

Sets the validation action.

public CollectionOptionsBuilder SetValidationAction(DocumentValidationAction validationAction)

Parameters

validationAction DocumentValidationAction

The validation action.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetValidationLevel(DocumentValidationLevel)

Sets the validation level.

public CollectionOptionsBuilder SetValidationLevel(DocumentValidationLevel validationLevel)

Parameters

validationLevel DocumentValidationLevel

The validation level.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

SetValidator(IMongoQuery)

Sets the validator.

public CollectionOptionsBuilder SetValidator(IMongoQuery validator)

Parameters

validator IMongoQuery

The validator.

Returns

CollectionOptionsBuilder

The builder (so method calls can be chained).

ToBsonDocument()

Returns the result of the builder as a BsonDocument.

public override BsonDocument ToBsonDocument()

Returns

BsonDocument

A BsonDocument.