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 seperate 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, Object[]).

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

    Inheritance
    System.Object
    CustomServiceQueryExtender<T>
    GetAllocationAmountsForEntities
    GetGLAllocationsForEntities
    GetGLPostingsForEntities
    GetTransactionAllocationsForEntities
    GetTransactionsForEntities
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: LemonEdge.Core
    Assembly: 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 MyProccess
    {
        public Task<IEnumerable<IGLPosting>> GetPostings(IEntityRetriever context, Guid[] instrumentIDs) =>
            context.ExecuteCustomQuery<IGLPosting>(nameof(GLPostingQueries.GetGLPostingsAgainstInstruments), new object[] { instrumentIDs });
    }

    Properties

    BaseItems

    The base set of IQueryable items to use within this query

    Declaration
    public IQueryable<T> BaseItems { get; set; }
    Property Value
    Type Description
    System.Linq.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
    System.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
    System.Threading.Tasks.Task

    A task indicating the completion of the operation

    Extension Methods

    MiscExtensions.SetIfNotEqual<T, P>(T, Expression<Func<T, P>>, P)
    ReflectionExtensions.ClearEventInvocations(Object, String)
    StringExtensions.ToCSVFormatString(Object, Type)
    SQLExtensions.ToSQLValue(Object, Boolean)

    See Also

    ICustomServiceQueryHelper
    In This Article
    Back to top © LemonTree Software Ltd. All rights reserved.