Class UpdateBuilder<TDocument>
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.
public UpdateBuilder()
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).
public UpdateBuilder<TDocument> AddToSetEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, IEnumerable<TValue> values)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
values
IEnumerable<TValue>The values to add to the set.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
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).
public UpdateBuilder<TDocument> AddToSet<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, TValue value)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
value
TValueThe value to add to the set.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
BitwiseAnd(Expression<Func<TDocument, int>>, int)
Sets the named element to the bitwise and of its value with another value (see $bit with "and").
public UpdateBuilder<TDocument> BitwiseAnd(Expression<Func<TDocument, int>> memberExpression, int value)
Parameters
memberExpression
Expression<Func<TDocument, int>>The member expression.
value
intThe value to be and-ed with the current value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
BitwiseAnd(Expression<Func<TDocument, long>>, long)
Sets the named element to the bitwise and of its value with another value (see $bit with "and").
public UpdateBuilder<TDocument> BitwiseAnd(Expression<Func<TDocument, long>> memberExpression, long value)
Parameters
memberExpression
Expression<Func<TDocument, long>>The member expression.
value
longThe value to be and-ed with the current value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
BitwiseOr(Expression<Func<TDocument, int>>, int)
Sets the named element to the bitwise or of its value with another value (see $bit with "or").
public UpdateBuilder<TDocument> BitwiseOr(Expression<Func<TDocument, int>> memberExpression, int value)
Parameters
memberExpression
Expression<Func<TDocument, int>>The member expression.
value
intThe value to be or-ed with the current value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
BitwiseOr(Expression<Func<TDocument, long>>, long)
Sets the named element to the bitwise or of its value with another value (see $bit with "or").
public UpdateBuilder<TDocument> BitwiseOr(Expression<Func<TDocument, long>> memberExpression, long value)
Parameters
memberExpression
Expression<Func<TDocument, long>>The member expression.
value
longThe value to be or-ed with the current value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
BitwiseXor(Expression<Func<TDocument, int>>, int)
Sets the named element to the bitwise xor of its value with another value (see $bit with "xor").
public UpdateBuilder<TDocument> BitwiseXor(Expression<Func<TDocument, int>> memberExpression, int value)
Parameters
memberExpression
Expression<Func<TDocument, int>>The member expression.
value
intThe value to be xor-ed with the current value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
BitwiseXor(Expression<Func<TDocument, long>>, long)
Sets the named element to the bitwise xor of its value with another value (see $bit with "xor").
public UpdateBuilder<TDocument> BitwiseXor(Expression<Func<TDocument, long>> memberExpression, long value)
Parameters
memberExpression
Expression<Func<TDocument, long>>The member expression.
value
longThe value to be xor-ed with the current value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Combine(IMongoUpdate)
Combines another UpdateBuilder into this one.
public UpdateBuilder<TDocument> Combine(IMongoUpdate other)
Parameters
other
IMongoUpdateThe UpdateBuilder to combine into this one.
Returns
- UpdateBuilder<TDocument>
A combined UpdateBuilder.
CurrentDate(Expression<Func<TDocument, BsonDateTime>>)
Sets the value of the named element to the current date (see $currentDate).
public UpdateBuilder<TDocument> CurrentDate(Expression<Func<TDocument, BsonDateTime>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, BsonDateTime>>The member expression.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
CurrentDate(Expression<Func<TDocument, BsonTimestamp>>)
Sets the value of the named element to the current date (see $currentDate).
public UpdateBuilder<TDocument> CurrentDate(Expression<Func<TDocument, BsonTimestamp>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, BsonTimestamp>>The member expression.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
CurrentDate(Expression<Func<TDocument, DateTime>>)
Sets the value of the named element to the current date (see $currentDate).
public UpdateBuilder<TDocument> CurrentDate(Expression<Func<TDocument, DateTime>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, DateTime>>The member expression.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Inc(Expression<Func<TDocument, double>>, double)
Increments the named element by a value (see $inc).
public UpdateBuilder<TDocument> Inc(Expression<Func<TDocument, double>> memberExpression, double value)
Parameters
memberExpression
Expression<Func<TDocument, double>>The member expression.
value
doubleThe value to increment by.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Inc(Expression<Func<TDocument, int>>, int)
Increments the named element by a value (see $inc).
public UpdateBuilder<TDocument> Inc(Expression<Func<TDocument, int>> memberExpression, int value)
Parameters
memberExpression
Expression<Func<TDocument, int>>The member expression.
value
intThe value to increment by.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Inc(Expression<Func<TDocument, long>>, long)
Increments the named element by a value (see $inc).
public UpdateBuilder<TDocument> Inc(Expression<Func<TDocument, long>> memberExpression, long value)
Parameters
memberExpression
Expression<Func<TDocument, long>>The member expression.
value
longThe value to increment by.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
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).
public UpdateBuilder<TDocument> Max<TMember>(Expression<Func<TDocument, TMember>> memberExpression, TMember value)
Parameters
memberExpression
Expression<Func<TDocument, TMember>>The member expression.
value
TMemberThe value to use.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TMember
The type of the member.
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).
public UpdateBuilder<TDocument> Min<TMember>(Expression<Func<TDocument, TMember>> memberExpression, TMember value)
Parameters
memberExpression
Expression<Func<TDocument, TMember>>The member expression.
value
TMemberThe value to use.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TMember
The type of the member.
Mul(Expression<Func<TDocument, double>>, double)
Multiplies the named element by a value (see $mul).
public UpdateBuilder<TDocument> Mul(Expression<Func<TDocument, double>> memberExpression, double value)
Parameters
memberExpression
Expression<Func<TDocument, double>>The member expression.
value
doubleThe value to multiply by.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Mul(Expression<Func<TDocument, int>>, int)
Multiplies the named element by a value (see $mul).
public UpdateBuilder<TDocument> Mul(Expression<Func<TDocument, int>> memberExpression, int value)
Parameters
memberExpression
Expression<Func<TDocument, int>>The member expression.
value
intThe value to multiply by.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Mul(Expression<Func<TDocument, long>>, long)
Multiplies the named element by a value (see $mul).
public UpdateBuilder<TDocument> Mul(Expression<Func<TDocument, long>> memberExpression, long value)
Parameters
memberExpression
Expression<Func<TDocument, long>>The member expression.
value
longThe value to multiply by.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
PopFirst<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>)
Removes the first value from the named array element (see $pop).
public UpdateBuilder<TDocument> PopFirst<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
PopLast<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>)
Removes the last value from the named array element (see $pop).
public UpdateBuilder<TDocument> PopLast<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
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).
public UpdateBuilder<TDocument> PullAll<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, IEnumerable<TValue> values)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
values
IEnumerable<TValue>The values to remove.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
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).
public UpdateBuilder<TDocument> Pull<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, Func<QueryBuilder<TValue>, IMongoQuery> elementQueryBuilderFunction)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
elementQueryBuilderFunction
Func<QueryBuilder<TValue>, IMongoQuery>A function that builds a query using the supplied query builder.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
Pull<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)
Removes all values from the named array element that are equal to some value (see $pull).
public UpdateBuilder<TDocument> Pull<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, TValue value)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
value
TValueThe value to remove.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
PushAll<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)
Adds a list of values to the end of the named array element (see $pushAll).
public UpdateBuilder<TDocument> PushAll<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, IEnumerable<TValue> values)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
values
IEnumerable<TValue>The values to add to the end of the array.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
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).
public UpdateBuilder<TDocument> PushEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, PushEachOptions options, IEnumerable<TValue> values)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The name of the array element.
options
PushEachOptionsThe options.
values
IEnumerable<TValue>The values to add to the end of the array.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the value.
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).
public UpdateBuilder<TDocument> PushEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, Action<PushEachOptionsBuilder<TValue>> options, IEnumerable<TValue> values)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The name of the array element.
options
Action<PushEachOptionsBuilder<TValue>>The options.
values
IEnumerable<TValue>The values to add to the end of the array.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the value.
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).
public UpdateBuilder<TDocument> PushEach<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, IEnumerable<TValue> values)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The name of the array element.
values
IEnumerable<TValue>The values to add to the end of the array.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the value.
Push<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)
Adds a value to the end of the named array element (see $push).
public UpdateBuilder<TDocument> Push<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, TValue value)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
value
TValueThe value to add to the end of the array.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
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).
public UpdateBuilder<TDocument> SetOnInsert<TMember>(Expression<Func<TDocument, TMember>> memberExpression, TMember value)
Parameters
memberExpression
Expression<Func<TDocument, TMember>>The member expression.
value
TMemberThe new value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TMember
The type of the member.
Set<TMember>(Expression<Func<TDocument, TMember>>, TMember)
Sets the value of the named element to a new value (see $set).
public UpdateBuilder<TDocument> Set<TMember>(Expression<Func<TDocument, TMember>> memberExpression, TMember value)
Parameters
memberExpression
Expression<Func<TDocument, TMember>>The member expression.
value
TMemberThe new value.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TMember
The type of the member.
ToBsonDocument()
Converts this object to a BsonDocument.
public override BsonDocument ToBsonDocument()
Returns
- BsonDocument
A BsonDocument.
Unset<TMember>(Expression<Func<TDocument, TMember>>)
Removes the named element from the document (see $unset).
public UpdateBuilder<TDocument> Unset<TMember>(Expression<Func<TDocument, TMember>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, TMember>>The member expression.
Returns
- UpdateBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TMember
The type of the member.