Search Results for

    Show / Hide Table of Contents

    Class Update<T>

    Represents an update command

    TIP: Specify a filter first with the .Match(). Then set property values with .Modify() and finally call .Execute() to run the command.

    Inheritance
    Object
    UpdateBase<T>
    Update<T>
    Inherited Members
    UpdateBase<T>.defs
    UpdateBase<T>.AddModification<TProp>(Expression<Func<T, TProp>>, TProp)
    UpdateBase<T>.AddModification(Func<UpdateDefinitionBuilder<T>, UpdateDefinition<T>>)
    UpdateBase<T>.AddModification(String)
    UpdateBase<T>.AddModification(Template)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: MongoDB.Entities
    Assembly: MongoDB.Entities.dll
    Syntax
    public class Update<T> : UpdateBase<T> where T : IEntity
    Type Parameters
    Name Description
    T

    Any class that implements IEntity

    Methods

    AddToQueue()

    Queue up an update command for bulk execution later.

    Declaration
    public Update<T> AddToQueue()
    Returns
    Type Description
    Update<T>

    ExecuteAsync(CancellationToken)

    Run the update command in MongoDB.

    Declaration
    public async Task<UpdateResult> ExecuteAsync(CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task<UpdateResult>

    ExecutePipelineAsync(CancellationToken)

    Run the update command with pipeline stages

    Declaration
    public Task<UpdateResult> ExecutePipelineAsync(CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task<UpdateResult>

    IgnoreGlobalFilters()

    Specify that this operation should ignore any global filters

    Declaration
    public Update<T> IgnoreGlobalFilters()
    Returns
    Type Description
    Update<T>

    Match(FilterDefinition<T>)

    Specify the matching criteria with a filter definition

    Declaration
    public Update<T> Match(FilterDefinition<T> filterDefinition)
    Parameters
    Type Name Description
    FilterDefinition<T> filterDefinition

    A filter definition

    Returns
    Type Description
    Update<T>

    Match(Search, String, Boolean, Boolean, String)

    Specify a search term to find results from the text index of this particular collection.

    TIP: Make sure to define a text index with DB.Index<T>() before searching

    Declaration
    public Update<T> Match(Search searchType, string searchTerm, bool caseSensitive = false, bool diacriticSensitive = false, string language = null)
    Parameters
    Type Name Description
    Search searchType

    The type of text matching to do

    String searchTerm

    The search term

    Boolean caseSensitive

    Case sensitivity of the search (optional)

    Boolean diacriticSensitive

    Diacritic sensitivity of the search (optional)

    String language

    The language for the search (optional)

    Returns
    Type Description
    Update<T>

    Match(Template)

    Specify the matching criteria with a template

    Declaration
    public Update<T> Match(Template template)
    Parameters
    Type Name Description
    Template template

    A Template with a find query

    Returns
    Type Description
    Update<T>

    Match(Func<FilterDefinitionBuilder<T>, FilterDefinition<T>>)

    Specify the matching criteria with a filter expression

    Declaration
    public Update<T> Match(Func<FilterDefinitionBuilder<T>, FilterDefinition<T>> filter)
    Parameters
    Type Name Description
    Func<FilterDefinitionBuilder<T>, FilterDefinition<T>> filter

    f => f.Eq(x => x.Prop, Value) & f.Gt(x => x.Prop, Value)

    Returns
    Type Description
    Update<T>

    Match(Expression<Func<T, Boolean>>)

    Specify the matching criteria with a lambda expression

    Declaration
    public Update<T> Match(Expression<Func<T, bool>> expression)
    Parameters
    Type Name Description
    Expression<Func<T, Boolean>> expression

    x => x.Property == Value

    Returns
    Type Description
    Update<T>

    Match(Expression<Func<T, Object>>, Coordinates2D, Nullable<Double>, Nullable<Double>)

    Specify criteria for matching entities based on GeoSpatial data (longitude & latitude)

    TIP: Make sure to define a Geo2DSphere index with DB.Index<T>() before searching

    Note: DB.FluentGeoNear() supports more advanced options

    Declaration
    public Update<T> Match(Expression<Func<T, object>> coordinatesProperty, Coordinates2D nearCoordinates, double? maxDistance = null, double? minDistance = null)
    Parameters
    Type Name Description
    Expression<Func<T, Object>> coordinatesProperty

    The property where 2DCoordinates are stored

    Coordinates2D nearCoordinates

    The search point

    Nullable<Double> maxDistance

    Maximum distance in meters from the search point

    Nullable<Double> minDistance

    Minimum distance in meters from the search point

    Returns
    Type Description
    Update<T>

    MatchExpression(Template)

    Specify the matching criteria with a Template

    Declaration
    public Update<T> MatchExpression(Template template)
    Parameters
    Type Name Description
    Template template

    A Template object

    Returns
    Type Description
    Update<T>

    MatchExpression(String)

    Specify the matching criteria with an aggregation expression (i.e. $expr)

    Declaration
    public Update<T> MatchExpression(string expression)
    Parameters
    Type Name Description
    String expression

    { $gt: ['$Property1', '$Property2'] }

    Returns
    Type Description
    Update<T>

    MatchID(String)

    Specify an IEntity ID as the matching criteria

    Declaration
    public Update<T> MatchID(string ID)
    Parameters
    Type Name Description
    String ID

    A unique IEntity ID

    Returns
    Type Description
    Update<T>

    MatchString(String)

    Specify the matching criteria with a JSON string

    Declaration
    public Update<T> MatchString(string jsonString)
    Parameters
    Type Name Description
    String jsonString

    { Title : 'The Power Of Now' }

    Returns
    Type Description
    Update<T>

    Modify(Template)

    Specify an update with a Template to modify the Entities (use multiple times if needed)

    Declaration
    public Update<T> Modify(Template template)
    Parameters
    Type Name Description
    Template template

    A Template with a single update

    Returns
    Type Description
    Update<T>

    Modify(Func<UpdateDefinitionBuilder<T>, UpdateDefinition<T>>)

    Specify the update definition builder operation to modify the Entities (use multiple times if needed)

    Declaration
    public Update<T> Modify(Func<UpdateDefinitionBuilder<T>, UpdateDefinition<T>> operation)
    Parameters
    Type Name Description
    Func<UpdateDefinitionBuilder<T>, UpdateDefinition<T>> operation

    b => b.Inc(x => x.PropName, Value)

    Returns
    Type Description
    Update<T>

    Modify(String)

    Specify an update (json string) to modify the Entities (use multiple times if needed)

    Declaration
    public Update<T> Modify(string update)
    Parameters
    Type Name Description
    String update

    { \(set: { &apos;RootProp.\)[x].SubProp' : 321 } }

    Returns
    Type Description
    Update<T>

    Modify<TProp>(Expression<Func<T, TProp>>, TProp)

    Specify the property and it's value to modify (use multiple times if needed)

    Declaration
    public Update<T> Modify<TProp>(Expression<Func<T, TProp>> property, TProp value)
    Parameters
    Type Name Description
    Expression<Func<T, TProp>> property

    x => x.Property

    TProp value

    The value to set on the property

    Returns
    Type Description
    Update<T>
    Type Parameters
    Name Description
    TProp

    ModifyExcept(Expression<Func<T, Object>>, T)

    Modify all EXCEPT the specified properties with the values from a given entity instance.

    Declaration
    public Update<T> ModifyExcept(Expression<Func<T, object>> members, T entity)
    Parameters
    Type Name Description
    Expression<Func<T, Object>> members

    Supply a new expression with the properties to exclude. Ex: x => new { x.Prop1, x.Prop2 }

    T entity

    The entity instance to read the corresponding values from

    Returns
    Type Description
    Update<T>

    ModifyOnly(Expression<Func<T, Object>>, T)

    Modify ONLY the specified properties with the values from a given entity instance.

    Declaration
    public Update<T> ModifyOnly(Expression<Func<T, object>> members, T entity)
    Parameters
    Type Name Description
    Expression<Func<T, Object>> members

    A new expression with the properties to include. Ex: x => new { x.PropOne, x.PropTwo }

    T entity

    The entity instance to read the corresponding values from

    Returns
    Type Description
    Update<T>

    ModifyWith(T)

    Modify ALL properties with the values from the supplied entity instance.

    Declaration
    public Update<T> ModifyWith(T entity)
    Parameters
    Type Name Description
    T entity

    The entity instance to read the property values from

    Returns
    Type Description
    Update<T>

    Option(Action<UpdateOptions>)

    Specify an option for this update command (use multiple times if needed)

    TIP: Setting options is not required

    Declaration
    public Update<T> Option(Action<UpdateOptions> option)
    Parameters
    Type Name Description
    Action<UpdateOptions> option

    x => x.OptionName = OptionValue

    Returns
    Type Description
    Update<T>

    WithArrayFilter(Template)

    Specify a single array filter using a Template to target nested entities for updates

    Declaration
    public Update<T> WithArrayFilter(Template template)
    Parameters
    Type Name Description
    Template template
    Returns
    Type Description
    Update<T>

    WithArrayFilter(String)

    Specify an array filter to target nested entities for updates (use multiple times if needed).

    Declaration
    public Update<T> WithArrayFilter(string filter)
    Parameters
    Type Name Description
    String filter

    { 'x.SubProp': { $gte: 123 } }

    Returns
    Type Description
    Update<T>

    WithArrayFilters(Template)

    Specify multiple array filters with a Template to target nested entities for updates.

    Declaration
    public Update<T> WithArrayFilters(Template template)
    Parameters
    Type Name Description
    Template template

    The template with an array [...] of filters

    Returns
    Type Description
    Update<T>

    WithPipeline(Template)

    Specify an update pipeline with multiple stages using a Template to modify the Entities.

    NOTE: pipeline updates and regular updates cannot be used together.

    Declaration
    public Update<T> WithPipeline(Template template)
    Parameters
    Type Name Description
    Template template

    A Template object containing multiple pipeline stages

    Returns
    Type Description
    Update<T>

    WithPipelineStage(Template)

    Specify an update pipeline stage using a Template to modify the Entities (use multiple times if needed)

    NOTE: pipeline updates and regular updates cannot be used together.

    Declaration
    public Update<T> WithPipelineStage(Template template)
    Parameters
    Type Name Description
    Template template

    A Template object containing a pipeline stage

    Returns
    Type Description
    Update<T>

    WithPipelineStage(String)

    Specify an update pipeline stage to modify the Entities (use multiple times if needed)

    NOTE: pipeline updates and regular updates cannot be used together.

    Declaration
    public Update<T> WithPipelineStage(string stage)
    Parameters
    Type Name Description
    String stage

    { $set: { FullName: { $concat: ['$Name', ' ', '$Surname'] } } }

    Returns
    Type Description
    Update<T>
    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX