Table of Contents

Method Add

Namespace
MongoDB.Bson
Assembly
MongoDB.Bson.dll

Add(BsonElement)

Adds an element to the document.

public override BsonDocument Add(BsonElement element)

Parameters

element BsonElement

The element to add.

Returns

BsonDocument

The document (so method calls can be chained).

Add(string, BsonValue)

Creates and adds an element to the document.

public override BsonDocument Add(string name, BsonValue value)

Parameters

name string

The name of the element.

value BsonValue

The value of the element.

Returns

BsonDocument

The document (so method calls can be chained).

Add(string, BsonValue, bool)

Creates and adds an element to the document, but only if the condition is true.

public override BsonDocument Add(string name, BsonValue value, bool condition)

Parameters

name string

The name of the element.

value BsonValue

The value of the element.

condition bool

Whether to add the element to the document.

Returns

BsonDocument

The document (so method calls can be chained).

Add(string, Func<BsonValue>, bool)

Creates and adds an element to the document, but only if the condition is true. If the condition is false the value factory is not called at all.

public override BsonDocument Add(string name, Func<BsonValue> valueFactory, bool condition)

Parameters

name string

The name of the element.

valueFactory Func<BsonValue>

A delegate called to compute the value of the element if condition is true.

condition bool

Whether to add the element to the document.

Returns

BsonDocument

The document (so method calls can be chained).