Search Results for

    Show / Hide Table of Contents

    Class One<T>

    Represents a one-to-one relationship with an IEntity.

    Inheritance
    Object
    One<T>
    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 class One<T>
        where T : IEntity
    Type Parameters
    Name Description
    T

    Any type that implements IEntity

    Constructors

    One()

    Declaration
    public One()

    One(T)

    Initializes a reference to an entity in MongoDB.

    Declaration
    public One(T entity)
    Parameters
    Type Name Description
    T entity

    The actual entity this reference represents.

    One(String)

    Initializes a reference to an entity in MongoDB.

    Declaration
    public One(string id)
    Parameters
    Type Name Description
    String id

    the ID of the referenced entity

    Properties

    ID

    The Id of the entity referenced by this instance.

    Declaration
    [AsObjectId]
    public string ID { get; set; }
    Property Value
    Type Description
    String

    Methods

    ToEntityAsync(IClientSessionHandle, CancellationToken)

    Fetches the actual entity this reference represents from the database.

    Declaration
    public Task<T> ToEntityAsync(IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    IClientSessionHandle session

    An optional session

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task<T>

    A Task containing the actual entity

    ToEntityAsync(Func<ProjectionDefinitionBuilder<T>, ProjectionDefinition<T, T>>, IClientSessionHandle, CancellationToken)

    Fetches the actual entity this reference represents from the database with a projection.

    Declaration
    public async Task<T> ToEntityAsync(Func<ProjectionDefinitionBuilder<T>, ProjectionDefinition<T, T>> projection, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    Func<ProjectionDefinitionBuilder<T>, ProjectionDefinition<T, T>> projection

    p=> p.Include("Prop1").Exclude("Prop2")

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task<T>

    A Task containing the actual projected entity

    ToEntityAsync(Expression<Func<T, T>>, IClientSessionHandle, CancellationToken)

    Fetches the actual entity this reference represents from the database with a projection.

    Declaration
    public async Task<T> ToEntityAsync(Expression<Func<T, T>> projection, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))
    Parameters
    Type Name Description
    Expression<Func<T, T>> projection

    x => new Test { PropName = x.Prop }

    IClientSessionHandle session

    An optional session if using within a transaction

    CancellationToken cancellation

    An optional cancellation token

    Returns
    Type Description
    Task<T>

    A Task containing the actual projected entity

    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX