Search Results for

    Show / Hide Table of Contents

    Class Many<TChild>

    Represents a one-to-many/many-to-many relationship between two Entities.

    WARNING: You have to initialize all instances of this class before accessing any of it's members.

    Initialize from the constructor of the parent entity as follows:

    this.InitOneToMany(() => Property);

    this.InitManyToMany(() => Property, x => x.OtherProperty);

    Inheritance
    Object
    ManyBase
    Many<TChild>
    Implements
    IEnumerable<TChild>
    IEnumerable
    Inherited Members
    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 sealed class Many<TChild> : ManyBase, IEnumerable<TChild>, IEnumerable where TChild : IEntity
    Type Parameters
    Name Description
    TChild

    Type of the child IEntity.

    Constructors

    Many()

    Creates an instance of Many<TChild> This is only needed in VB.Net

    Declaration
    public Many()

    Properties

    JoinCollection

    Gets the IMongoCollection of JoinRecords for this relationship.

    TIP: Try never to use this unless really neccessary.

    Declaration
    public IMongoCollection<JoinRecord> JoinCollection { get; }
    Property Value
    Type Description
    IMongoCollection<JoinRecord>

    Methods

    AddAsync(TChild, IClientSessionHandle, CancellationToken)

    Adds a new child reference.

    WARNING: Make sure to save the parent and child Entities before calling this method.

    Declaration
    public Task AddAsync(TChild child, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    TChild child

    The child Entity to add.

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    AddAsync(IEnumerable<TChild>, IClientSessionHandle, CancellationToken)

    Adds multiple child references in a single bulk operation

    WARNING: Make sure to save the parent and child Entities before calling this method.

    Declaration
    public Task AddAsync(IEnumerable<TChild> children, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    IEnumerable<TChild> children

    The child Entities to add

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    AddAsync(IEnumerable<String>, IClientSessionHandle, CancellationToken)

    Adds multiple child references in a single bulk operation

    WARNING: Make sure to save the parent and child Entities before calling this method.

    Declaration
    public Task AddAsync(IEnumerable<string> childIDs, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    IEnumerable<String> childIDs

    The IDs of the child Entities to add.

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    AddAsync(String, IClientSessionHandle, CancellationToken)

    Adds a new child reference.

    WARNING: Make sure to save the parent and child Entities before calling this method.

    Declaration
    public Task AddAsync(string childID, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    String childID

    The ID of the child Entity to add.

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    ChildrenCountAsync(IClientSessionHandle, CountOptions, CancellationToken)

    Get the number of children for a relationship

    Declaration
    public Task<long> ChildrenCountAsync(IClientSessionHandle session = null, CountOptions options = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    IClientSessionHandle session

    An optional session if using within a transaction

    CountOptions options

    An optional AggregateOptions object

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task<Int64>

    ChildrenFluent(IClientSessionHandle, AggregateOptions)

    An IAggregateFluent of child Entities for the parent.

    Declaration
    public IAggregateFluent<TChild> ChildrenFluent(IClientSessionHandle session = null, AggregateOptions options = null)
    Parameters
    Type Name Description
    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IAggregateFluent<TChild>

    ChildrenQueryable(IClientSessionHandle, AggregateOptions)

    An IQueryable of child Entities for the parent.

    Declaration
    public IMongoQueryable<TChild> ChildrenQueryable(IClientSessionHandle session = null, AggregateOptions options = null)
    Parameters
    Type Name Description
    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IMongoQueryable<TChild>

    GetEnumerator()

    Declaration
    public IEnumerator<TChild> GetEnumerator()
    Returns
    Type Description
    IEnumerator<TChild>

    JoinFluent(IClientSessionHandle, AggregateOptions)

    An IAggregateFluent of JoinRecords for this relationship

    Declaration
    public IAggregateFluent<JoinRecord> JoinFluent(IClientSessionHandle session = null, AggregateOptions options = null)
    Parameters
    Type Name Description
    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IAggregateFluent<JoinRecord>

    JoinQueryable(IClientSessionHandle, AggregateOptions)

    An IQueryable of JoinRecords for this relationship

    Declaration
    public IMongoQueryable<JoinRecord> JoinQueryable(IClientSessionHandle session = null, AggregateOptions options = null)
    Parameters
    Type Name Description
    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IMongoQueryable<JoinRecord>

    ParentsFluent<TParent>(IAggregateFluent<TChild>)

    Get an IAggregateFluent of parents matching a supplied IAggregateFluent of children for this relationship.

    Declaration
    public IAggregateFluent<TParent> ParentsFluent<TParent>(IAggregateFluent<TChild> children)
        where TParent : IEntity
    Parameters
    Type Name Description
    IAggregateFluent<TChild> children

    An IAggregateFluent of children

    Returns
    Type Description
    IAggregateFluent<TParent>
    Type Parameters
    Name Description
    TParent

    The type of the parent IEntity

    ParentsFluent<TParent>(IEnumerable<String>, IClientSessionHandle, AggregateOptions)

    Get an IAggregateFluent of parents matching multiple child IDs for this relationship.

    Declaration
    public IAggregateFluent<TParent> ParentsFluent<TParent>(IEnumerable<string> childIDs, IClientSessionHandle session = null, AggregateOptions options = null)
        where TParent : IEntity
    Parameters
    Type Name Description
    IEnumerable<String> childIDs

    An IEnumerable of child IDs

    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IAggregateFluent<TParent>
    Type Parameters
    Name Description
    TParent

    The type of the parent IEntity

    ParentsFluent<TParent>(String, IClientSessionHandle, AggregateOptions)

    Get an IAggregateFluent of parents matching a single child ID for this relationship.

    Declaration
    public IAggregateFluent<TParent> ParentsFluent<TParent>(string childID, IClientSessionHandle session = null, AggregateOptions options = null)
        where TParent : IEntity
    Parameters
    Type Name Description
    String childID

    An child ID

    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IAggregateFluent<TParent>
    Type Parameters
    Name Description
    TParent

    The type of the parent IEntity

    ParentsQueryable<TParent>(IMongoQueryable<TChild>, IClientSessionHandle, AggregateOptions)

    Get an IQueryable of parents matching a supplied IQueryable of children for this relationship.

    Declaration
    [Obsolete("This method is no longer supported due to incompatibilities with LINQ3 translation engine!", true)]
    public IMongoQueryable<TParent> ParentsQueryable<TParent>(IMongoQueryable<TChild> children, IClientSessionHandle session = null, AggregateOptions options = null)
        where TParent : IEntity
    Parameters
    Type Name Description
    IMongoQueryable<TChild> children

    An IQueryable of children

    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IMongoQueryable<TParent>
    Type Parameters
    Name Description
    TParent

    The type of the parent IEntity

    ParentsQueryable<TParent>(IEnumerable<String>, IClientSessionHandle, AggregateOptions)

    Get an IQueryable of parents matching multiple child IDs for this relationship.

    Declaration
    public IMongoQueryable<TParent> ParentsQueryable<TParent>(IEnumerable<string> childIDs, IClientSessionHandle session = null, AggregateOptions options = null)
        where TParent : IEntity
    Parameters
    Type Name Description
    IEnumerable<String> childIDs

    An IEnumerable of child IDs

    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IMongoQueryable<TParent>
    Type Parameters
    Name Description
    TParent

    The type of the parent IEntity

    ParentsQueryable<TParent>(String, IClientSessionHandle, AggregateOptions)

    Get an IQueryable of parents matching a single child ID for this relationship.

    Declaration
    public IMongoQueryable<TParent> ParentsQueryable<TParent>(string childID, IClientSessionHandle session = null, AggregateOptions options = null)
        where TParent : IEntity
    Parameters
    Type Name Description
    String childID

    A child ID

    IClientSessionHandle session

    An optional session if using within a transaction

    AggregateOptions options

    An optional AggregateOptions object

    Returns
    Type Description
    IMongoQueryable<TParent>
    Type Parameters
    Name Description
    TParent

    The type of the parent IEntity

    RemoveAsync(TChild, IClientSessionHandle, CancellationToken)

    Removes a child reference.

    Declaration
    public Task RemoveAsync(TChild child, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    TChild child

    The child IEntity to remove the reference of.

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    RemoveAsync(IEnumerable<TChild>, IClientSessionHandle, CancellationToken)

    Removes child references.

    Declaration
    public Task RemoveAsync(IEnumerable<TChild> children, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    IEnumerable<TChild> children

    The child Entities to remove the references of.

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    RemoveAsync(IEnumerable<String>, IClientSessionHandle, CancellationToken)

    Removes child references.

    Declaration
    public Task RemoveAsync(IEnumerable<string> childIDs, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    IEnumerable<String> childIDs

    The IDs of the child Entities to remove the references of

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    RemoveAsync(String, IClientSessionHandle, CancellationToken)

    Removes a child reference.

    Declaration
    public Task RemoveAsync(string childID, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    String childID

    The ID of the child Entity to remove the reference of.

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task

    VB_InitManyToMany<TParent>(TParent, Expression<Func<TParent, Object>>, Expression<Func<TChild, Object>>, Boolean)

    Use this method to initialize the Many<TChild> properties with VB.Net

    Declaration
    public void VB_InitManyToMany<TParent>(TParent parent, Expression<Func<TParent, object>> propertyParent, Expression<Func<TChild, object>> propertyChild, bool isInverse)
        where TParent : IEntity
    Parameters
    Type Name Description
    TParent parent

    The parent entity instance

    Expression<Func<TParent, Object>> propertyParent

    Function(x) x.ParentProp

    Expression<Func<TChild, Object>> propertyChild

    Function(x) x.ChildProp

    Boolean isInverse

    Specify if this is the inverse side of the relationship or not

    Type Parameters
    Name Description
    TParent

    The type of the parent

    VB_InitOneToMany<TParent>(TParent, Expression<Func<TParent, Object>>)

    Use this method to initialize the Many<TChild> properties with VB.Net

    Declaration
    public void VB_InitOneToMany<TParent>(TParent parent, Expression<Func<TParent, object>> property)
        where TParent : IEntity
    Parameters
    Type Name Description
    TParent parent

    The parent entity instance

    Expression<Func<TParent, Object>> property

    Function(x) x.PropName

    Type Parameters
    Name Description
    TParent

    The type of the parent

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    Implements

    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    Extension Methods

    Extensions.DeleteAllAsync<T>(IEnumerable<T>, IClientSessionHandle, CancellationToken)
    Extensions.InsertAsync<T>(IEnumerable<T>, IClientSessionHandle, CancellationToken)
    Extensions.SaveAsync<T>(IEnumerable<T>, IClientSessionHandle, CancellationToken)
    Extensions.SaveExceptAsync<T>(IEnumerable<T>, IEnumerable<String>, IClientSessionHandle, CancellationToken)
    Extensions.SaveExceptAsync<T>(IEnumerable<T>, Expression<Func<T, Object>>, IClientSessionHandle, CancellationToken)
    Extensions.SaveOnlyAsync<T>(IEnumerable<T>, IEnumerable<String>, IClientSessionHandle, CancellationToken)
    Extensions.SaveOnlyAsync<T>(IEnumerable<T>, Expression<Func<T, Object>>, IClientSessionHandle, CancellationToken)
    Extensions.SortByRelevance<T>(IEnumerable<T>, String, Func<T, String>, Nullable<Int32>)
    Extensions.ToBatches<T>(IEnumerable<T>, Int32)
    Extensions.ToDocuments<T>(IEnumerable<T>)
    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX