Search Results for

    Show / Hide Table of Contents

    Class BaseSQLWrapperExecuter<SW, T>

    A base class for executing a sql wrapper and enumerating the results

    Inheritance
    object
    BaseSQLWrapperExecuter<SW, T>
    SQLWrapperExecuter
    SQLWrapperExecuter<T>
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: LemonEdge.API.Entities.Helpers
    Assembly: LemonEdge.API.dll
    Syntax
    public abstract class BaseSQLWrapperExecuter<SW, T> where SW : BaseSQLWrapperExecuter<SW, T>
    Type Parameters
    Name Description
    SW

    The type of BaseSQLWrapperExecuter itself

    T

    The type of item to be enumerated when the sql wrapper is executed

    Constructors

    BaseSQLWrapperExecuter(ISQLWrapper, IEntityRetriever, IReadOnlyCache)

    Creates a new BaseSQLWrapper for the specified sql wrapper

    Declaration
    public BaseSQLWrapperExecuter(ISQLWrapper sqlWrapper, IEntityRetriever retriever, IReadOnlyCache cache)
    Parameters
    Type Name Description
    ISQLWrapper sqlWrapper

    The actual sql wrapper to execute

    IEntityRetriever retriever

    A context to execute the sql wrapper with

    IReadOnlyCache cache

    A local cache

    BaseSQLWrapperExecuter(Guid, IEntityRetriever, IReadOnlyCache)

    Creates a new BaseSQLWrapper for the specified sql wrapper

    Declaration
    public BaseSQLWrapperExecuter(Guid sqlWrapperID, IEntityRetriever retriever, IReadOnlyCache cache)
    Parameters
    Type Name Description
    Guid sqlWrapperID

    The unique global id of the sql wrapper to execute

    IEntityRetriever retriever

    A context to execute the sql wrapper with

    IReadOnlyCache cache

    A local cache

    BaseSQLWrapperExecuter(string, IEntityRetriever, IReadOnlyCache)

    Creates a new BaseSQLWrapper for the specified sql wrapper

    Declaration
    public BaseSQLWrapperExecuter(string sqlWrapperName, IEntityRetriever retriever, IReadOnlyCache cache)
    Parameters
    Type Name Description
    string sqlWrapperName

    The name of the sql wrapper to execute - must match exactly

    IEntityRetriever retriever

    A context to execute the sql wrapper with

    IReadOnlyCache cache

    A local cache

    Fields

    _params

    Declaration
    protected Dictionary<string, string> _params
    Field Value
    Type Description
    Dictionary<string, string>

    _sqlWrapper

    Declaration
    protected ISQLWrapper _sqlWrapper
    Field Value
    Type Description
    ISQLWrapper

    _sqlWrapperID

    Declaration
    protected readonly Guid? _sqlWrapperID
    Field Value
    Type Description
    Guid?

    _sqlWrapperName

    Declaration
    protected readonly string _sqlWrapperName
    Field Value
    Type Description
    string

    Properties

    Cache

    A local context cache

    Declaration
    public IReadOnlyCache Cache { get; }
    Property Value
    Type Description
    IReadOnlyCache

    Filter

    Any filters provided by the user through SetFilter(QueryableExecuter<T>) to be applied to this sql wrapper before executing it

    Declaration
    public QueryableExecuter<T> Filter { get; }
    Property Value
    Type Description
    QueryableExecuter<T>

    Parameters

    The parameters for running this sql wrapper query

    Declaration
    public Dictionary<string, string> Parameters { get; }
    Property Value
    Type Description
    Dictionary<string, string>

    Retriever

    The context the sql wrapper will be executed against

    Declaration
    public IEntityRetriever Retriever { get; }
    Property Value
    Type Description
    IEntityRetriever

    Methods

    AddAsOfDate(DateTimeOffset)

    Adds an as of date for running the sql wrapper query as of a specified point in the past. If this is not set, it is automatically determined from the context in Retriever

    Declaration
    public virtual BaseSQLWrapperExecuter<SW, T> AddAsOfDate(DateTimeOffset asOfDate)
    Parameters
    Type Name Description
    DateTimeOffset asOfDate

    The date to run this query as of in the past

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    AddCanvasID(Guid)

    Adds the id of a canvas for running the sql wrapper query in. If this is not set, it is automatically determined from the context in Retriever

    Declaration
    public virtual BaseSQLWrapperExecuter<SW, T> AddCanvasID(Guid canvasID)
    Parameters
    Type Name Description
    Guid canvasID

    The canvas to run this sql wrapper in

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    AddParameter(string, bool)

    Adds the specified value for the specified parameter

    Declaration
    public BaseSQLWrapperExecuter<SW, T> AddParameter(string paramName, bool paramValue)
    Parameters
    Type Name Description
    string paramName

    The unique name of the sql wrapper parameter (coming from ParameterName)

    bool paramValue

    The boolean value for this parameter

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    AddParameter<V>(string, V?)

    Adds the specified value for the specified parameter

    Declaration
    public BaseSQLWrapperExecuter<SW, T> AddParameter<V>(string paramName, V? paramValue) where V : struct
    Parameters
    Type Name Description
    string paramName

    The unique name of the sql wrapper parameter (coming from ParameterName)

    V? paramValue

    The nullable value for this parameter

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    Type Parameters
    Name Description
    V

    The type of the value

    AddParameter<V>(string, V)

    Adds the specified value for the specified parameter

    Declaration
    public BaseSQLWrapperExecuter<SW, T> AddParameter<V>(string paramName, V paramValue)
    Parameters
    Type Name Description
    string paramName

    The unique name of the sql wrapper parameter (coming from ParameterName)

    V paramValue

    The value for this parameter

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    Type Parameters
    Name Description
    V

    The type of value

    AddParameters(IReadOnlyDictionary<string, string>)

    Adds the specified value for the specified parameter

    Declaration
    public BaseSQLWrapperExecuter<SW, T> AddParameters(IReadOnlyDictionary<string, string> parameters)
    Parameters
    Type Name Description
    IReadOnlyDictionary<string, string> parameters

    The parameters for this wrapper

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    ClearFilter()

    Clears any existing filter for this SQL Wrapper Executer

    Declaration
    public BaseSQLWrapperExecuter<SW, T> ClearFilter()
    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    ClearParameters()

    Clears all parameters

    Declaration
    public BaseSQLWrapperExecuter<SW, T> ClearParameters()
    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    Execute(CancellationToken)

    Executes this sql wrapper using the provided parameters and filter

    Declaration
    public abstract Task<IEnumerable<T>> Execute(CancellationToken token = default)
    Parameters
    Type Name Description
    CancellationToken token
    Returns
    Type Description
    Task<IEnumerable<T>>

    An enumeration of the results for this sql wrapper execution

    ExecuteCount()

    Executes the count of the results of this sql wrapper using the provided parameters and filter

    Declaration
    public abstract Task<int> ExecuteCount()
    Returns
    Type Description
    Task<int>

    The count of results for executing this sql wrapper with the provided parameters and filter

    GetFilter()

    By default returns the current Filter specified for this sql wrapper executer.

    Can be overridden by inheriting classes to provide a default filter if the current filter is null and has not been provided

    Declaration
    protected virtual QueryableExecuter<T> GetFilter()
    Returns
    Type Description
    QueryableExecuter<T>

    The filters to be applicaed before executing this sql wrapper executer

    GetQueryArgumentsAndFilter()

    Declaration
    protected (string paramArguments, string queryFilter) GetQueryArgumentsAndFilter()
    Returns
    Type Description
    (string paramArguments, string queryFilter)

    GetWrapper()

    Returns the SQL Wrapper to be executed.

    This executer may have been created with just the id or name of a sql wrapper, in which case it has to load it from the cache before it can return it

    Declaration
    public Task<ISQLWrapper> GetWrapper()
    Returns
    Type Description
    Task<ISQLWrapper>

    The SQL Wrapper to be executed.

    ParametersAreValid()

    Indicates if the parameters for running this sql wrapper executer are valid.

    If invalid the GetQueryArgumentsAndFilter() method will throw an exception

    Declaration
    protected virtual bool ParametersAreValid()
    Returns
    Type Description
    bool

    True if the current parameters for this query are valid, false if not

    SetFilter(QueryableExecuter<T>)

    Sets the specified filter to be incorporated into the sql wrapper while executed to efficiently filter the results being returned

    Declaration
    public BaseSQLWrapperExecuter<SW, T> SetFilter(QueryableExecuter<T> filter)
    Parameters
    Type Name Description
    QueryableExecuter<T> filter

    A QueryableExecuter holding the filter to be applied to this SQL Wrapper Executer before executing it

    Returns
    Type Description
    BaseSQLWrapperExecuter<SW, T>

    This instance, for chaining commands

    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)
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.