Method AddToSet

| MongoDB CSharp Driver API Reference (original) (raw)

Namespace

MongoDB.Driver

Assembly

MongoDB.Driver.dll

AddToSet<TDocument, TItem>(UpdateDefinition, FieldDefinition, TItem)

Combines an existing update with an add to set operator.

public static UpdateDefinition<TDocument> AddToSet<TDocument, TItem>(this UpdateDefinition<TDocument> update, FieldDefinition<TDocument> field, TItem value)

Parameters

update UpdateDefinition

The update.

field FieldDefinition

The field.

value TItem

The value.

Returns

UpdateDefinition

A combined update.

Type Parameters

TDocument

The type of the document.

TItem

The type of the item.

AddToSet<TDocument, TItem>(UpdateDefinition, Expression<Func<TDocument, IEnumerable>>, TItem)

Combines an existing update with an add to set operator.

public static UpdateDefinition<TDocument> AddToSet<TDocument, TItem>(this UpdateDefinition<TDocument> update, Expression<Func<TDocument, IEnumerable<TItem>>> field, TItem value)

Parameters

update UpdateDefinition

The update.

field Expression<Func<TDocument, IEnumerable>>

The field.

value TItem

The value.

Returns

UpdateDefinition

A combined update.

Type Parameters

TDocument

The type of the document.

TItem

The type of the item.