Table of Contents

Class UpdateBuilder<TDocument>

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

A builder for creating update modifiers.

[Serializable]
[BsonSerializer(typeof(UpdateBuilder<>.Serializer))]
public class UpdateBuilder<TDocument> : BuilderBase, IConvertibleToBsonDocument, IMongoUpdate

Type Parameters

TDocument

The type of the document.

Inheritance
UpdateBuilder<TDocument>
Implements
Inherited Members
Extension Methods

Constructors

UpdateBuilder()

Initializes a new instance of the UpdateBuilder class.

Methods

AddToSetEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Adds a list of values to a named array element adding each value only if it not already in the array (see $addToSet and $each).

AddToSet<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Adds a value to a named array element if the value is not already in the array (see $addToSet).

BitwiseAnd(Expression<Func<TDocument, int>>, int)

Sets the named element to the bitwise and of its value with another value (see $bit with "and").

BitwiseAnd(Expression<Func<TDocument, long>>, long)

Sets the named element to the bitwise and of its value with another value (see $bit with "and").

BitwiseOr(Expression<Func<TDocument, int>>, int)

Sets the named element to the bitwise or of its value with another value (see $bit with "or").

BitwiseOr(Expression<Func<TDocument, long>>, long)

Sets the named element to the bitwise or of its value with another value (see $bit with "or").

BitwiseXor(Expression<Func<TDocument, int>>, int)

Sets the named element to the bitwise xor of its value with another value (see $bit with "xor").

BitwiseXor(Expression<Func<TDocument, long>>, long)

Sets the named element to the bitwise xor of its value with another value (see $bit with "xor").

Combine(IMongoUpdate)

Combines another UpdateBuilder into this one.

CurrentDate(Expression<Func<TDocument, BsonDateTime>>)

Sets the value of the named element to the current date (see $currentDate).

CurrentDate(Expression<Func<TDocument, BsonTimestamp>>)

Sets the value of the named element to the current date (see $currentDate).

CurrentDate(Expression<Func<TDocument, DateTime>>)

Sets the value of the named element to the current date (see $currentDate).

Inc(Expression<Func<TDocument, double>>, double)

Increments the named element by a value (see $inc).

Inc(Expression<Func<TDocument, int>>, int)

Increments the named element by a value (see $inc).

Inc(Expression<Func<TDocument, long>>, long)

Increments the named element by a value (see $inc).

Max<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Updates the named element if and only if the provided value is greater than its current value (see $max).

Min<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Updates the named element if and only if the provided value is less than its current value (see $max).

Mul(Expression<Func<TDocument, double>>, double)

Multiplies the named element by a value (see $mul).

Mul(Expression<Func<TDocument, int>>, int)

Multiplies the named element by a value (see $mul).

Mul(Expression<Func<TDocument, long>>, long)

Multiplies the named element by a value (see $mul).

PopFirst<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>)

Removes the first value from the named array element (see $pop).

PopLast<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>)

Removes the last value from the named array element (see $pop).

PullAll<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Removes all values from the named array element that are equal to any of a list of values (see $pullAll).

Pull<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, Func<QueryBuilder<TValue>, IMongoQuery>)

Removes all values from the named array element that match some query (see $pull).

Pull<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Removes all values from the named array element that are equal to some value (see $pull).

PushAll<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Adds a list of values to the end of the named array element (see $pushAll).

PushEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, PushEachOptions, IEnumerable<TValue>)

Adds a list of values to the end of the named array element (see $push and $each).

PushEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, Action<PushEachOptionsBuilder<TValue>>, IEnumerable<TValue>)

Adds a list of values to the end of the named array element (see $push and $each).

PushEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Adds a list of values to the end of the named array element (see $push and $each).

Push<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Adds a value to the end of the named array element (see $push).

SetOnInsert<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Sets the value of the named element to the specified value only when an insert occurs as part of an upsert operation (see $setOnInsert).

Set<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Sets the value of the named element to a new value (see $set).

ToBsonDocument()

Converts this object to a BsonDocument.

Unset<TMember>(Expression<Func<TDocument, TMember>>)

Removes the named element from the document (see $unset).