Method Add
Add(BsonElement)
Adds an element to the document.
public virtual BsonDocument Add(BsonElement element)
Parameters
elementBsonElementThe element to add.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(Dictionary<string, object>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange instead.")]
public virtual BsonDocument Add(Dictionary<string, object> dictionary)
Parameters
dictionaryDictionary<string, object>The dictionary.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(Dictionary<string, object>, IEnumerable<string>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public virtual BsonDocument Add(Dictionary<string, object> dictionary, IEnumerable<string> keys)
Parameters
dictionaryDictionary<string, object>The dictionary.
keysIEnumerable<string>Which keys of the hash table to add.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(IDictionary<string, object>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange instead.")]
public virtual BsonDocument Add(IDictionary<string, object> dictionary)
Parameters
dictionaryIDictionary<string, object>The dictionary.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(IDictionary<string, object>, IEnumerable<string>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public virtual BsonDocument Add(IDictionary<string, object> dictionary, IEnumerable<string> keys)
Parameters
dictionaryIDictionary<string, object>The dictionary.
keysIEnumerable<string>Which keys of the hash table to add.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(IDictionary)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange instead.")]
public virtual BsonDocument Add(IDictionary dictionary)
Parameters
dictionaryIDictionaryThe dictionary.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(IDictionary, IEnumerable)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public virtual BsonDocument Add(IDictionary dictionary, IEnumerable keys)
Parameters
dictionaryIDictionaryThe dictionary.
keysIEnumerableWhich keys of the hash table to add.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(IEnumerable<BsonElement>)
Adds a list of elements to the document.
[Obsolete("Use AddRange instead.")]
public virtual BsonDocument Add(IEnumerable<BsonElement> elements)
Parameters
elementsIEnumerable<BsonElement>The list of elements.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(params BsonElement[])
Adds a list of elements to the document.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public virtual BsonDocument Add(params BsonElement[] elements)
Parameters
elementsBsonElement[]The list of elements.
Returns
- BsonDocument
The document (so method calls can be chained).
Add(string, BsonValue)
Creates and adds an element to the document.
public virtual BsonDocument Add(string name, BsonValue value)
Parameters
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 virtual BsonDocument Add(string name, BsonValue value, bool condition)
Parameters
namestringThe name of the element.
valueBsonValueThe value of the element.
conditionboolWhether 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 virtual BsonDocument Add(string name, Func<BsonValue> valueFactory, bool condition)
Parameters
namestringThe name of the element.
valueFactoryFunc<BsonValue>A delegate called to compute the value of the element if condition is true.
conditionboolWhether to add the element to the document.
Returns
- BsonDocument
The document (so method calls can be chained).