Search Results for

    Show / Hide Table of Contents

    Class CustomServiceQueryExtender<T>

    This class can be inherited by any custom code to provide a mechanism of creating queries that join across items without having to use separate IEntityRetriever queries.

    As IEntityRetriever encapsulates the connection (web or direct database connection) for the client, this provides a mechanism to run LINQ queries regardless

    Any class created inheriting from this can be called using ExecuteCustomQuery<T>(string, params object[]).

    The constructed IQueryable should be compatible with dynamic Linq translations to SQL

    Inheritance
    object
    CustomServiceQueryExtender<T>
    EntitiesInEntitySetsOrCanOwnInstrumentsQuery
    ValidTransactionCodesQuery
    StructureAllocQueries
    StructureLegalQueries
    GetAllocationAmountsForEntities
    GetGLAllocationsForEntities
    GetGLPostingsForEntities
    GetSplitTransactionsForStepChange
    GetTransactionAllocationsForEntities
    GetTransactionsForEntities
    GetTransactionsForStepChange
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: LemonEdge.API.Core.Data
    Assembly: LemonEdge.API.dll
    Syntax
    public abstract class CustomServiceQueryExtender<T> where T : IBaseEntity
    Type Parameters
    Name Description
    T

    The type of item that is returned from executing this custom query

    Remarks

    For example, we can use the following to create a query that looks at transactions and their postings:

    public class GLPostingQueries : CustomServiceQueryExtender<API.Entities.IGLPosting>
    {
    
        public IQueryable<IGLPosting> GetGLPostingsAgainstInstruments(Guid[] instrumentIDs)
        {
            var trans = Helper.GetQueryableItems<API.Entities.ITransaction>().Where(x => x.InstrumentID.HasValue && instrumentIDs.Contains(x.InstrumentID.Value));
    
            return from p in BaseItems
            join t in trans on p.ParentTransactionID equals t.ID
            select p;
        }
    }

    Which we can call anywhere by using something similar to the following:

    public class MyProcess
    {
        public Task<IEnumerable<IGLPosting>> GetPostings(IEntityRetriever context, Guid[] instrumentIDs) =>
            context.ExecuteCustomQuery<IGLPosting>(nameof(GLPostingQueries.GetGLPostingsAgainstInstruments), new object[] { instrumentIDs });
    }

    Constructors

    CustomServiceQueryExtender()

    Declaration
    protected CustomServiceQueryExtender()

    Properties

    BaseItems

    The base set of IQueryable items to use within this query

    Declaration
    public IQueryable<T> BaseItems { get; set; }
    Property Value
    Type Description
    IQueryable<T>

    BaseItemsForType

    Indicates the sub type to use for the item type if they are part of a replicated type such as Permissions

    Declaration
    public virtual Guid BaseItemsForType { get; }
    Property Value
    Type Description
    Guid

    Helper

    An abstracted helper class that provides functionality to assist building your IQueryable query

    Declaration
    public ICustomServiceQueryHelper Helper { get; set; }
    Property Value
    Type Description
    ICustomServiceQueryHelper

    Methods

    Init()

    An initialization that allows you to preload any required data for the query itself, such as information from the local Cache using Cache

    Declaration
    public virtual Task Init()
    Returns
    Type Description
    Task

    A task indicating the completion of the operation

    Extension Methods

    LinqExtensions.AsArray<T>(T)
    LinqExtensions.ToArrayOfOne<T>(T)
    LinqExtensions.ToListOfOne<T>(T)
    MiscExtensions.SetIfNotEqual<T, TP>(T, Expression<Func<T, TP>>, TP)
    WeakReferenceExtensions.WeakReference(object)
    SQLExtensions.ToSQLValue(object, bool)
    ReflectionExtensions.ClearEventInvocations(object, string)
    StringExtensions.ToCSVFormatString(object, Type)

    See Also

    ICustomServiceQueryHelper
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.