Class UpdateBuilder
A builder for creating update modifiers.
[Serializable]
[BsonSerializer(typeof(UpdateBuilder.Serializer))]
public class UpdateBuilder : BuilderBase, IConvertibleToBsonDocument, IMongoUpdate
- Inheritance
-
UpdateBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
UpdateBuilder()
Initializes a new instance of the UpdateBuilder class.
public UpdateBuilder()
Methods
AddToSet(string, BsonValue)
Adds a value to a named array element if the value is not already in the array (see $addToSet).
public UpdateBuilder AddToSet(string name, BsonValue value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
AddToSetEach(string, BsonArray)
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 AddToSetEach(string name, BsonArray values)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
AddToSetEach(string, params BsonValue[])
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 AddToSetEach(string name, params BsonValue[] values)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
AddToSetEach(string, IEnumerable<BsonValue>)
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 AddToSetEach(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<BsonValue>The values to add to the set.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
AddToSetEachWrapped<T>(string, IEnumerable<T>)
Adds a list of wrapped values to a named array element adding each value only if it not already in the array (see $addToSet and $each).
public UpdateBuilder AddToSetEachWrapped<T>(string name, IEnumerable<T> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<T>The wrapped values to add to the set.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped values.
AddToSetEachWrapped<T>(string, params T[])
Adds a list of wrapped values to a named array element adding each value only if it not already in the array (see $addToSet and $each).
public UpdateBuilder AddToSetEachWrapped<T>(string name, params T[] values)
Parameters
name
stringThe name of the array element.
values
T[]The wrapped values to add to the set.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped values.
AddToSetWrapped<T>(string, T)
Adds a wrapped value to a named array element if the value is not already in the array (see $addToSet).
public UpdateBuilder AddToSetWrapped<T>(string name, T value)
Parameters
name
stringThe name of the array element.
value
TThe wrapped value to add to the set.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
BitwiseAnd(string, int)
Sets the named element to the bitwise and of its value with another value (see $bit with "and").
public UpdateBuilder BitwiseAnd(string name, int value)
Parameters
name
stringThe name of the element to be modified.
value
intThe value to be and-ed with the current value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
BitwiseAnd(string, long)
Sets the named element to the bitwise and of its value with another value (see $bit with "and").
public UpdateBuilder BitwiseAnd(string name, long value)
Parameters
name
stringThe name of the element to be modified.
value
longThe value to be and-ed with the current value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
BitwiseOr(string, int)
Sets the named element to the bitwise or of its value with another value (see $bit with "or").
public UpdateBuilder BitwiseOr(string name, int value)
Parameters
name
stringThe name of the element to be modified.
value
intThe value to be or-ed with the current value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
BitwiseOr(string, long)
Sets the named element to the bitwise or of its value with another value (see $bit with "or").
public UpdateBuilder BitwiseOr(string name, long value)
Parameters
name
stringThe name of the element to be modified.
value
longThe value to be or-ed with the current value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
BitwiseXor(string, int)
Sets the named element to the bitwise xor of its value with another value (see $bit with "xor").
public UpdateBuilder BitwiseXor(string name, int value)
Parameters
name
stringThe name of the element to be modified.
value
intThe value to be xor-ed with the current value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
BitwiseXor(string, long)
Sets the named element to the bitwise xor of its value with another value (see $bit with "xor").
public UpdateBuilder BitwiseXor(string name, long value)
Parameters
name
stringThe name of the element to be modified.
value
longThe value to be xor-ed with the current value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Combine(IMongoUpdate)
Combines another UpdateBuilder into this one.
public UpdateBuilder Combine(IMongoUpdate other)
Parameters
other
IMongoUpdateThe IMongoUpdate to combine into this one.
Returns
- UpdateBuilder
A combined UpdateBuilder.
CurrentDate(string)
Sets the value of the named element to the current date (see $currentDate).
public UpdateBuilder CurrentDate(string name)
Parameters
name
stringThe name of the element.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
CurrentDate(string, UpdateCurrentDateType)
Sets the value of the named element to the current date (see $currentDate).
public UpdateBuilder CurrentDate(string name, UpdateCurrentDateType type)
Parameters
name
stringThe name of the element.
type
UpdateCurrentDateTypeThe type to use.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Inc(string, double)
Increments the named element by a value (see $inc).
public UpdateBuilder Inc(string name, double value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Inc(string, int)
Increments the named element by a value (see $inc).
public UpdateBuilder Inc(string name, int value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Inc(string, long)
Increments the named element by a value (see $inc).
public UpdateBuilder Inc(string name, long value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Max(string, BsonValue)
Updates the named element if and only if the provided value is greater than its current value (see $max).
public UpdateBuilder Max(string name, BsonValue value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Min(string, BsonValue)
Updates the named element if and only if the provided value is less than its current value (see $max).
public UpdateBuilder Min(string name, BsonValue value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Mul(string, double)
Multiplies the named element by a value (see $mul).
public UpdateBuilder Mul(string name, double value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Mul(string, int)
Multiplies the named element by a value (see $mul).
public UpdateBuilder Mul(string name, int value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Mul(string, long)
Multiplies the named element by a value (see $mul).
public UpdateBuilder Mul(string name, long value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PopFirst(string)
Removes the first value from the named array element (see $pop).
public UpdateBuilder PopFirst(string name)
Parameters
name
stringThe name of the array element.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PopLast(string)
Removes the last value from the named array element (see $pop).
public UpdateBuilder PopLast(string name)
Parameters
name
stringThe name of the array element.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Pull(string, BsonValue)
Removes all values from the named array element that are equal to some value (see $pull).
public UpdateBuilder Pull(string name, BsonValue value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Pull(string, IMongoQuery)
Removes all values from the named array element that match some query (see $pull).
public UpdateBuilder Pull(string name, IMongoQuery query)
Parameters
name
stringThe name of the array element.
query
IMongoQueryA query that specifies which elements to remove.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PullAll(string, BsonArray)
Removes all values from the named array element that are equal to any of a list of values (see $pullAll).
public UpdateBuilder PullAll(string name, BsonArray values)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PullAll(string, params BsonValue[])
Removes all values from the named array element that are equal to any of a list of values (see $pullAll).
public UpdateBuilder PullAll(string name, params BsonValue[] values)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PullAll(string, IEnumerable<BsonValue>)
Removes all values from the named array element that are equal to any of a list of values (see $pullAll).
public UpdateBuilder PullAll(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<BsonValue>The values to remove.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PullAllWrapped<T>(string, IEnumerable<T>)
Removes all values from the named array element that are equal to any of a list of wrapped values (see $pullAll).
public UpdateBuilder PullAllWrapped<T>(string name, IEnumerable<T> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<T>The wrapped values to remove.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped values.
PullAllWrapped<T>(string, params T[])
Removes all values from the named array element that are equal to any of a list of wrapped values (see $pullAll).
public UpdateBuilder PullAllWrapped<T>(string name, params T[] values)
Parameters
name
stringThe name of the array element.
values
T[]The wrapped values to remove.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped values.
PullWrapped<T>(string, T)
Removes all values from the named array element that are equal to some wrapped value (see $pull).
public UpdateBuilder PullWrapped<T>(string name, T value)
Parameters
name
stringThe name of the array element.
value
TThe wrapped value to remove.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
Push(string, BsonValue)
Adds a value to the end of the named array element (see $push).
public UpdateBuilder Push(string name, BsonValue value)
Parameters
name
stringThe name of the array element.
value
BsonValueThe value to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushAll(string, BsonArray)
Adds a list of values to the end of the named array element (see $pushAll).
public UpdateBuilder PushAll(string name, BsonArray values)
Parameters
name
stringThe name of the array element.
values
BsonArrayThe values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushAll(string, params BsonValue[])
Adds a list of values to the end of the named array element (see $pushAll).
public UpdateBuilder PushAll(string name, params BsonValue[] values)
Parameters
name
stringThe name of the array element.
values
BsonValue[]The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushAll(string, IEnumerable<BsonValue>)
Adds a list of values to the end of the named array element (see $pushAll).
public UpdateBuilder PushAll(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<BsonValue>The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushAllWrapped<T>(string, IEnumerable<T>)
Adds a list of wrapped values to the end of the named array element (see $pushAll).
public UpdateBuilder PushAllWrapped<T>(string name, IEnumerable<T> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<T>The wrapped values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped values.
PushAllWrapped<T>(string, params T[])
Adds a list of wrapped values to the end of the named array element (see $pushAll).
public UpdateBuilder PushAllWrapped<T>(string name, params T[] values)
Parameters
name
stringThe name of the array element.
values
T[]The wrapped values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped values.
PushEach(string, BsonArray)
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEach(string name, BsonArray values)
Parameters
name
stringThe name of the array element.
values
BsonArrayThe values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushEach(string, params BsonValue[])
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEach(string name, params BsonValue[] values)
Parameters
name
stringThe name of the array element.
values
BsonValue[]The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushEach(string, PushEachOptions, BsonArray)
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEach(string name, PushEachOptions options, BsonArray values)
Parameters
name
stringThe name of the array element.
options
PushEachOptionsThe options.
values
BsonArrayThe values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushEach(string, PushEachOptions, params BsonValue[])
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEach(string name, PushEachOptions options, params BsonValue[] values)
Parameters
name
stringThe name of the array element.
options
PushEachOptionsThe options.
values
BsonValue[]The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushEach(string, PushEachOptions, IEnumerable<BsonValue>)
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEach(string name, PushEachOptions options, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the array element.
options
PushEachOptionsThe options.
values
IEnumerable<BsonValue>The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushEach(string, IEnumerable<BsonValue>)
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEach(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<BsonValue>The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
PushEachWrapped<T>(string, PushEachOptions, IEnumerable<T>)
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEachWrapped<T>(string name, PushEachOptions args, IEnumerable<T> values)
Parameters
name
stringThe name of the array element.
args
PushEachOptionsThe args.
values
IEnumerable<T>The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
PushEachWrapped<T>(string, PushEachOptions, params T[])
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEachWrapped<T>(string name, PushEachOptions args, params T[] values)
Parameters
name
stringThe name of the array element.
args
PushEachOptionsThe args.
values
T[]The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
PushEachWrapped<T>(string, IEnumerable<T>)
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEachWrapped<T>(string name, IEnumerable<T> values)
Parameters
name
stringThe name of the array element.
values
IEnumerable<T>The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
PushEachWrapped<T>(string, params T[])
Adds a list of values to the end of the named array element (see $push and $each).
public UpdateBuilder PushEachWrapped<T>(string name, params T[] values)
Parameters
name
stringThe name of the array element.
values
T[]The values to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
PushWrapped<T>(string, T)
Adds a wrapped value to the end of the named array element (see $push).
public UpdateBuilder PushWrapped<T>(string name, T value)
Parameters
name
stringThe name of the array element.
value
TThe wrapped value to add to the end of the array.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
Rename(string, string)
Renames an element (see $rename).
public UpdateBuilder Rename(string oldElementName, string newElementName)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Set(string, BsonValue)
Sets the value of the named element to a new value (see $set).
public UpdateBuilder Set(string name, BsonValue value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
SetOnInsert(string, BsonValue)
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 SetOnInsert(string name, BsonValue value)
Parameters
Returns
- UpdateBuilder
The builder (so method calls can be chained).
SetWrapped<T>(string, T)
Sets the value of the named element to a new wrapped value (see $set).
public UpdateBuilder SetWrapped<T>(string name, T value)
Parameters
name
stringThe name of the element to be set.
value
TThe new wrapped value.
Returns
- UpdateBuilder
The builder (so method calls can be chained).
Type Parameters
T
The type of wrapped value.
ToBsonDocument()
Returns the result of the builder as a BsonDocument.
public override BsonDocument ToBsonDocument()
Returns
- BsonDocument
A BsonDocument.
Unset(string)
Removes the named element from the document (see $unset).
public UpdateBuilder Unset(string name)
Parameters
name
stringThe name of the element to be removed.
Returns
- UpdateBuilder
The builder (so method calls can be chained).