Search Results for

    Show / Hide Table of Contents

    Class FormulaFunctions

    The context supplied while executing custom formulas.

    Contains all standard functions provided by StandardFunctions

    Inheritance
    object
    StandardFunctions
    FormulaFunctions
    FormulaFunctionsWithQueryRunnerResults
    FormulaFunctionsWithUpdater
    Implements
    IFormulaFunctions
    Inherited Members
    StandardFunctions.FormatAsString(object)
    StandardFunctions.Null()
    StandardFunctions.IsNull(object)
    StandardFunctions.Not(bool)
    StandardFunctions.Or(bool, bool)
    StandardFunctions.And(bool, bool)
    StandardFunctions.Sin(double)
    StandardFunctions.Cos(double)
    StandardFunctions.Now()
    StandardFunctions.Today()
    StandardFunctions.TodayString()
    StandardFunctions.EndOfMonth(DateTime)
    StandardFunctions.BeginningOfMonth(DateTime)
    StandardFunctions.BeginningOfWeek(DateTime)
    StandardFunctions.EndOfYear(DateTime)
    StandardFunctions.EndOfDay(DateTime)
    StandardFunctions.Floor(decimal)
    StandardFunctions.Ceiling(decimal)
    StandardFunctions.BeginningOfYear(DateTime)
    StandardFunctions.BeginningOfDay(DateTime)
    StandardFunctions.Random(int, int)
    StandardFunctions.Trim(string)
    StandardFunctions.TrimStart(string, char[])
    StandardFunctions.TrimEnd(string, char[])
    StandardFunctions.PadLeft(string, int, char)
    StandardFunctions.PadRight(string, int, char)
    StandardFunctions.Mod(double, double)
    StandardFunctions.If(bool, object, object)
    StandardFunctions.IsIn(object, object)
    StandardFunctions.IsIn(object, object, object)
    StandardFunctions.IsIn(object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object, object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object, object, object, object, object, object)
    StandardFunctions.IsIn(object, object, object, object, object, object, object, object, object, object, object)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.SelectCase(object, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>, Func<Task<object>>)
    StandardFunctions.Format(object, string)
    StandardFunctions.Lower(string)
    StandardFunctions.Upper(string)
    StandardFunctions.WCase(string)
    StandardFunctions.Date(int, int, int)
    StandardFunctions.Year(DateTime)
    StandardFunctions.Month(DateTime)
    StandardFunctions.Day(DateTime)
    StandardFunctions.WeekDay(DateTime)
    StandardFunctions.Replace(string, string, string)
    StandardFunctions.Substr(string, int, int)
    StandardFunctions.Len(string)
    StandardFunctions.Abs(double)
    StandardFunctions.Int(object)
    StandardFunctions.Trunc(double, int)
    StandardFunctions.Dec(object)
    StandardFunctions.Round(object)
    StandardFunctions.IsBlank(string)
    StandardFunctions.Round(object, int)
    StandardFunctions.Min(double, double, double, double, double)
    StandardFunctions.Max(double, double, double, double, double)
    StandardFunctions.Chr(int)
    StandardFunctions.ChCR()
    StandardFunctions.ChLF()
    StandardFunctions.ChCRLF()
    StandardFunctions.Money(object)
    StandardFunctions.Contains(string, string)
    StandardFunctions.FormatDate(DateTime, string)
    StandardFunctions.Sqrt(double)
    StandardFunctions.Power(double, double)
    StandardFunctions.ValString(object)
    StandardFunctions.ValBool(object)
    StandardFunctions.ValDate(object)
    StandardFunctions.ValDateTimeOffset(object)
    StandardFunctions.ValDecimal(object)
    StandardFunctions.ValLong(object)
    StandardFunctions.ValID(object)
    StandardFunctions.DateAdd(DateTime, decimal, decimal, decimal)
    StandardFunctions.DateAdd(DateTimeOffset, decimal, decimal, decimal)
    StandardFunctions.DateAddWorkDays(DateTime, decimal)
    StandardFunctions.DateAdd(DateTime, DateTime)
    StandardFunctions.DayDifference(DateTime, DateTime)
    StandardFunctions.DayDifferenceWorkDays(DateTime, DateTime)
    StandardFunctions.HourDifference(DateTime, DateTime)
    StandardFunctions.MinuteDifference(DateTime, DateTime)
    StandardFunctions.YearDifference(DateTime, DateTime)
    StandardFunctions.NullDate()
    StandardFunctions.NullDateTimeOffset()
    StandardFunctions.TempValue1
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: LemonEdge.API.Core.Formulas
    Assembly: LemonEdge.API.dll
    Syntax
    public class FormulaFunctions : StandardFunctions, IFormulaFunctions

    Constructors

    FormulaFunctions(IEntityRetriever, IReadOnlyCache, UserInfo, IFormulaFunctionsServiceContext)

    Creates a new formula functions for helping with custom formulas as a context to operate against

    Declaration
    public FormulaFunctions(IEntityRetriever retriever, IReadOnlyCache cache, UserInfo user, IFormulaFunctionsServiceContext services)
    Parameters
    Type Name Description
    IEntityRetriever retriever

    A context allowing formulas to load and query any data from LemonEdge

    IReadOnlyCache cache

    A local cache

    UserInfo user

    The current user executing the formula

    IFormulaFunctionsServiceContext services

    The services demanded from the IServiceProvider

    Properties

    Cache

    A local cache for retrieving already loaded standing data

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

    Data

    A context that allows you to retrieve and query any data from the LemonEdge system for evaluation

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

    Services

    The services demanded from the IServiceProvider that are utilized in the formula

    Declaration
    public IFormulaFunctionsServiceContext Services { get; }
    Property Value
    Type Description
    IFormulaFunctionsServiceContext

    User

    The current user running the formula

    Declaration
    public UserInfo User { get; }
    Property Value
    Type Description
    UserInfo

    Methods

    Evaluate<T>(string, bool)

    Evaluates the specified formula and returns the result as the specified T using the IScriptHelper

    Declaration
    public Task<T> Evaluate<T>(string formula, bool compileOnly = false)
    Parameters
    Type Name Description
    string formula

    The formula, or script, to be parsed and evaluated

    bool compileOnly

    Whether to just compile the script for the purpose of initialisation, or also execute it.

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T

    GetContextItemType(object)

    Returns the entity name of the type this item is

    Declaration
    [FormulaFunction(Name = "GetContextItemType", Type = "Other", Description = "Returns the type name of the object this formula is executing against. For instance if executing against a fund it would return \"Fund\". Returns \"\" if there is no context objext.", Params = "", ParamCount = 0)]
    public string GetContextItemType(object source)
    Parameters
    Type Name Description
    object source

    An item to return the name of the type for

    Returns
    Type Description
    string

    The name of the type this item is

    Remarks

    This is the name of the entity type as defined in the ItemName attribute property

    GetDRQueryItems(string, string, string, string)

    Declaration
    public Task<DataRow[]> GetDRQueryItems(string queryName, string parameters, string filter, string orderBy)
    Parameters
    Type Name Description
    string queryName
    string parameters
    string filter
    string orderBy
    Returns
    Type Description
    Task<DataRow[]>

    GetEntityTypeID(string)

    Declaration
    [FormulaFunction(Name = "GetEntityTypeID", Type = "Main", Description = "Returns the type id of a given custom entity, or system entity, from the supplied entity name.", Params = "1. The name of the entity to return the type id for.", ParamCount = 1, IsAsync = false)]
    public Guid GetEntityTypeID(string entityName)
    Parameters
    Type Name Description
    string entityName
    Returns
    Type Description
    Guid

    GetEnumCode(object)

    Returns the code of the specified enum value

    Can be the value itself, or if it has a specified enum value uses that instead, from EnumCode

    Declaration
    [FormulaFunction(Name = "GetEnumCode", Type = "Main", Description = "Returns the code of the specified enum value. Can be the value itself, or if it has a specified enum value uses that instead, from ICustomListItem.EnumCode.", Params = "1. The enum value.", ParamCount = 1, IsAsync = false)]
    public string GetEnumCode(object value)
    Parameters
    Type Name Description
    object value

    The enum value

    Returns
    Type Description
    string

    The code of the specified enum value

    GetEnumValue(object)

    Returns the value of the specified enum value

    Can be the value itself, or if it has a specified enum value uses that instead, from EnumValue

    Declaration
    [FormulaFunction(Name = "GetEnumValue", Type = "Main", Description = "Returns the value of the specified enum value. Can be the value itself, or if it has a specified enum value uses that instead, from ICustomListItem.EnumValue.", Params = "1. The enum value.", ParamCount = 1, IsAsync = false)]
    public decimal GetEnumValue(object value)
    Parameters
    Type Name Description
    object value

    The enum value

    Returns
    Type Description
    decimal

    The value of the specified enum value

    GetExtendedObject(IBaseEntity, string, bool)

    Declaration
    [FormulaFunction(Name = "GetExtendedObject", Type = "Main", Description = "Gets an extended custom entity object for the specified item.", Params = "1. The main item to get an extended object from.\r\n2. The name of the extended custom entity.\r\n3. If the extended item doesn't yet exist marking this true will create it and return the object (with no properties set). With false null will be returned.", ParamCount = 3, IsAsync = true)]
    public Task<object> GetExtendedObject(IBaseEntity item, string extendedTypeName, bool alwaysCreate)
    Parameters
    Type Name Description
    IBaseEntity item
    string extendedTypeName
    bool alwaysCreate
    Returns
    Type Description
    Task<object>

    GetExtendedPropertyItem(IBaseEntity, string)

    Declaration
    protected Task<IBaseEntity> GetExtendedPropertyItem(IBaseEntity item, string extendedTypeName)
    Parameters
    Type Name Description
    IBaseEntity item
    string extendedTypeName
    Returns
    Type Description
    Task<IBaseEntity>

    GetExtendedPropertyValue(IBaseEntity, string, string)

    Declaration
    [FormulaFunction(Name = "GetExtendedPropertyValue", Type = "Main", Description = "Gets the value for the specified item for a extended custom property of it.", Params = "1. The main item to get an extended property for.\r\n2. The name of the extended custom entity.\r\n3. The name of the of the property on the extended type to retrieve the value of.", ParamCount = 3, IsAsync = true)]
    public Task<object> GetExtendedPropertyValue(IBaseEntity item, string extendedTypeName, string extendedPropertyName)
    Parameters
    Type Name Description
    IBaseEntity item
    string extendedTypeName
    string extendedPropertyName
    Returns
    Type Description
    Task<object>

    GetFirstOrDefaultItem(string, QueryableFilter)

    Returns the first IBaseEntities in a collection of the specified type that match the provided filter

    Declaration
    [FormulaFunction(Name = "GetFirstOrDefaultItem", Type = "Main", Description = "Returns the first IBaseEntities in a collection of the specified type that match the provided filter", Params = "1. The name of the type you want to return items for.\r\n2. The LemonEdge.Utils.QueryableFilter to use to filter the results", ParamCount = 2, IsAsync = true)]
    public Task<IBaseEntity> GetFirstOrDefaultItem(string typeName, QueryableFilter filter)
    Parameters
    Type Name Description
    string typeName

    The entity type name (as defined in ItemName attribute property) of the type of object to return

    QueryableFilter filter

    The queryable filter to filter the results

    Returns
    Type Description
    Task<IBaseEntity>

    GetFirstOrDefaultItem(string, string, SQLOperator, object)

    Returns the first IBaseEntities in a collection of the specified type that match the provided filter

    Declaration
    [FormulaFunction(Name = "GetFirstOrDefaultItem", Type = "Main", Description = "Returns the first IBaseEntities in a collection of the specified type that match the provided filter", Params = "1. The name of the type you want to return items for.\r\n2. The column name to filter by\r\n3. The LemonEdge.Utils.Database.SQLOperator to filter the column by\r\n4. The value to filter the column by", ParamCount = 4, IsAsync = true)]
    public Task<IBaseEntity> GetFirstOrDefaultItem(string typeName, string columnName, SQLOperator op, object value)
    Parameters
    Type Name Description
    string typeName

    The entity type name (as defined in ItemName attribute property) of the type of object to return

    string columnName

    The column name to filter on

    SQLOperator op

    The operation to filter the column by

    object value

    The value to filter the column name by

    Returns
    Type Description
    Task<IBaseEntity>

    GetFirstOrDefaultItem<T>(QueryableFilter)

    Declaration
    [FormulaFunction(Name = "GetFirstOrDefaultItem", Type = "Main", Description = "Returns the first IBaseEntities in a collection of the specified type <T> that match the provided filter", Params = "1. The LemonEdge.Utils.QueryableFilter to use to filter the results", ParamCount = 1, IsAsync = true)]
    public Task<T> GetFirstOrDefaultItem<T>(QueryableFilter filter) where T : IBaseEntity
    Parameters
    Type Name Description
    QueryableFilter filter
    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T

    GetFirstOrDefaultItem<T>(string, SQLOperator, object)

    Declaration
    [FormulaFunction(Name = "GetFirstOrDefaultItem", Type = "Main", Description = "Returns the first IBaseEntities in a collection of the specified type <T> that match the provided filter", Params = "1. The column name to filter by\r\n2. The LemonEdge.Utils.Database.SQLOperator to filter the column by\r\n3. The value to filter the column by", ParamCount = 3, IsAsync = true)]
    public Task<T> GetFirstOrDefaultItem<T>(string columnName, SQLOperator op, object value) where T : IBaseEntity
    Parameters
    Type Name Description
    string columnName
    SQLOperator op
    object value
    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T

    GetItem(string, Guid)

    Returns an instance of the specified object type from its id

    Declaration
    [FormulaFunction(Name = "GetItem", Type = "Main", Description = "Returns an instance of the specified object type from its id.", Params = "1. The name of the type you want to return items for.\r\n2. The objects id", ParamCount = 2, IsAsync = true)]
    public Task<IBaseEntity> GetItem(string typeName, Guid id)
    Parameters
    Type Name Description
    string typeName

    The entity type name (as defined in ItemName attribute property) of the type of object to return

    Guid id

    The id of the item to return

    Returns
    Type Description
    Task<IBaseEntity>

    GetItemAs<T>(Guid)

    Returns an instance of the specified object type from its id

    Declaration
    [FormulaFunction(Name = "GetItemAs", Type = "Main", Description = "Returns an instance of the specified object type <T> from its id.", Params = "1. The objects id", ParamCount = 1, IsAsync = true)]
    public Task<T> GetItemAs<T>(Guid id) where T : IBaseEntity
    Parameters
    Type Name Description
    Guid id

    The id of the item to return

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T

    GetItemFromDataSourceID(string, string)

    Returns the id of the specified object a matching value of the specified data source key.

    Declaration
    [FormulaFunction(Name = "GetItemFromDataSourceID", Type = "Main", Description = "Returns the id of the specified object a matching value of the specified data source key.", Params = "1. The name of the data source type you are providing a key value to search for.\r\n2. The value of the data source key to search for and return the matching entity of", ParamCount = 2, IsAsync = true)]
    public Task<Guid?> GetItemFromDataSourceID(string datasourceTypeName, string datasourceID)
    Parameters
    Type Name Description
    string datasourceTypeName

    The name of the data source type you are providing a key value to search for

    string datasourceID

    The value of the data source key to search for and return the matching entity of

    Returns
    Type Description
    Task<Guid?>

    The id of the specified object a matching value of the specified data source key

    GetItemFromDataSourceID(string, string, string)

    Returns the id of the specified object a matching value of the specified data source key.

    Declaration
    [FormulaFunction(Name = "GetItemFromDataSourceID", Type = "Main", Description = "Returns the id of the specified object a matching value of the specified data source key.", Params = "1. The name of the type you want to return an id of.\r\n2. The name of the data source type you are providing a key value to search for.\r\n3. The value of the data source key to search for and return the matching entity of", ParamCount = 3, IsAsync = true)]
    public Task<Guid?> GetItemFromDataSourceID(string typeName, string datasourceTypeName, string datasourceID)
    Parameters
    Type Name Description
    string typeName

    The name of the type you want to return an id of

    string datasourceTypeName

    The name of the data source type you are providing a key value to search for

    string datasourceID

    The value of the data source key to search for and return the matching entity of

    Returns
    Type Description
    Task<Guid?>

    The id of the specified object a matching value of the specified data source key

    GetItemPropertyValue(object, string)

    Returns the value for a specified propName against an item

    Declaration
    public object GetItemPropertyValue(object item, string propName)
    Parameters
    Type Name Description
    object item

    The item to return the value of the specified property from

    string propName

    The property to return the value from

    Returns
    Type Description
    object

    The value for a specified propName against an item

    GetItems(string, QueryableFilter)

    Returns a collection of IBaseEntities of the specified type that match the provided filter

    Declaration
    [FormulaFunction(Name = "GetItems", Type = "Main", Description = "Returns a collection of IBaseEntities of the specified type that match the provided filter.", Params = "1. The name of the type you want to return items for.\r\n2. The LemonEdge.Utils.QueryableFilter to use to filter the results", ParamCount = 2, IsAsync = true)]
    public Task<IEnumerable<IBaseEntity>> GetItems(string typeName, QueryableFilter filter)
    Parameters
    Type Name Description
    string typeName

    The entity type name (as defined in ItemName attribute property) of the type of object to return

    QueryableFilter filter

    The queryable filter to filter the results

    Returns
    Type Description
    Task<IEnumerable<IBaseEntity>>

    GetItems(string, string, SQLOperator, object)

    Returns a collection of IBaseEntities of the specified type that match the provided filter

    Declaration
    [FormulaFunction(Name = "GetItems", Type = "Main", Description = "Returns a collection of IBaseEntities of the specified type that match the provided filter.", Params = "1. The name of the type you want to return items for.\r\n2. The column name to filter by\r\n3. The LemonEdge.Utils.Database.SQLOperator to filter the column by\r\n4. The value to filter the column by", ParamCount = 4, IsAsync = true)]
    public Task<IEnumerable<IBaseEntity>> GetItems(string typeName, string columnName, SQLOperator op, object value)
    Parameters
    Type Name Description
    string typeName

    The entity type name (as defined in ItemName attribute property) of the type of object to return

    string columnName

    The column name to filter on

    SQLOperator op

    The operation to filter the column by

    object value

    The value to filter the column name by

    Returns
    Type Description
    Task<IEnumerable<IBaseEntity>>

    GetItems<T>(QueryableFilter)

    Declaration
    [FormulaFunction(Name = "GetItems", Type = "Main", Description = "Returns a collection of the specified type <T> that match the provided filter.", Params = "1. The LemonEdge.Utils.QueryableFilter to use to filter the results", ParamCount = 1, IsAsync = true)]
    public Task<IEnumerable<T>> GetItems<T>(QueryableFilter filter) where T : IBaseEntity
    Parameters
    Type Name Description
    QueryableFilter filter
    Returns
    Type Description
    Task<IEnumerable<T>>
    Type Parameters
    Name Description
    T

    GetItems<T>(string, SQLOperator, object)

    Declaration
    [FormulaFunction(Name = "GetItems", Type = "Main", Description = "Returns a collection of the specified type <T> that match the provided filter.", Params = "1. The column name to filter by\r\n2. The LemonEdge.Utils.Database.SQLOperator to filter the column by\r\n3. The value to filter the column by", ParamCount = 3, IsAsync = true)]
    public Task<IEnumerable<T>> GetItems<T>(string columnName, SQLOperator op, object value) where T : IBaseEntity
    Parameters
    Type Name Description
    string columnName
    SQLOperator op
    object value
    Returns
    Type Description
    Task<IEnumerable<T>>
    Type Parameters
    Name Description
    T

    GetObjectValue(object, string)

    Declaration
    [FormulaFunction(Name = "GetObjectValue", Type = "Main", Description = "Returns the value for the specified property for the specified item.", Params = "1. The item to get the property value of.\r\n2. The name of the property to retrieve.", ParamCount = 2, IsAsync = false)]
    public object GetObjectValue(object item, string propertyName)
    Parameters
    Type Name Description
    object item
    string propertyName
    Returns
    Type Description
    object

    GetQueryCount(string, string, string)

    Executes the specified ISQLWrapper and returns the count of results.

    Declaration
    public Task<int> GetQueryCount(string queryName, string parameters, string filter)
    Parameters
    Type Name Description
    string queryName

    The name of the ISQLWrapper to execute

    string parameters

    Any parameters for executing the query in the form: @ParamName1=value1, @ParamName2=value2, ...

    string filter

    A filter of the form XXX OP Value. See ParseWhere(Type, string)

    Returns
    Type Description
    Task<int>

    GetQueryItems(string, string, string, string)

    Executes the specified ISQLWrapper and returns all the results. You can use the SQLWrapperInterpretor helper class for evaluating the results

    Declaration
    public Task<ISQLWrapperResult[]> GetQueryItems(string queryName, string parameters, string filter, string orderBy)
    Parameters
    Type Name Description
    string queryName

    The name of the ISQLWrapper to execute

    string parameters

    Any parameters for executing the query in the form: @ParamName1=value1, @ParamName2=value2, ...

    string filter

    A filter of the form XXX OP Value. See ParseWhere(Type, string)

    string orderBy

    Comma separated order by ascending/descending. See ParseSort(string, Func<string, string>)

    Returns
    Type Description
    Task<ISQLWrapperResult[]>
    See Also
    SQLWrapperInterpretor

    GetQueryResult(ISQLWrapperResult, string)

    Declaration
    [FormulaFunction(Name = "GetQueryResult", Type = "Queries", Description = "Given a row returned from RunQueryResult, it can be passed in here to get any value.", Params = "1. The query result to get the value from\r\n2. The name of the column to return", ParamCount = 2, IsAsync = true)]
    public Task<object> GetQueryResult(ISQLWrapperResult result, string columnName)
    Parameters
    Type Name Description
    ISQLWrapperResult result
    string columnName
    Returns
    Type Description
    Task<object>

    GetQueryResult(DataRow, string)

    Declaration
    public Task<object> GetQueryResult(DataRow result, string columnName)
    Parameters
    Type Name Description
    DataRow result
    string columnName
    Returns
    Type Description
    Task<object>

    GetQueryResult(string, string, ISQLWrapperResult)

    Declaration
    [FormulaFunction(Name = "GetQueryResult", Type = "Queries", Description = "Given a row returned from RunQueryResult, it can be passed in here to get any value.", Params = "1. The name of the query you want to return.\r\n2. The name of the column to return\r\n3. The query result to get the value from", ParamCount = 3, IsAsync = true)]
    public Task<object> GetQueryResult(string queryName, string columnName, ISQLWrapperResult result)
    Parameters
    Type Name Description
    string queryName
    string columnName
    ISQLWrapperResult result
    Returns
    Type Description
    Task<object>

    GetQueryResult(string, string, ISQLWrapperResult[], string, object)

    Declaration
    [FormulaFunction(Name = "GetQueryResult", Type = "Queries", Description = "Given rows returned from RunQueryResult, it can be passed in here to get any value where a specifiec column has a specified result.", Params = "1. The name of the query you want to return.\r\n2. The name of the column to return\r\n3. The query results to get the value from\r\n4. The name of the column to filter the resuls by\r\n5. The value the result should have", ParamCount = 5, IsAsync = true)]
    public Task<object> GetQueryResult(string queryName, string columnName, ISQLWrapperResult[] results, string whereColName, object equalsValue)
    Parameters
    Type Name Description
    string queryName
    string columnName
    ISQLWrapperResult[] results
    string whereColName
    object equalsValue
    Returns
    Type Description
    Task<object>

    GetQueryResult(string, string, DataRow)

    Declaration
    public Task<object> GetQueryResult(string queryName, string columnName, DataRow result)
    Parameters
    Type Name Description
    string queryName
    string columnName
    DataRow result
    Returns
    Type Description
    Task<object>

    GetTaskID(string)

    Declaration
    [FormulaFunction(Name = "GetTaskID", Type = "Tasks", Description = "Returns the ID for the specified task type.", Params = "1. The name of the server task type.", ParamCount = 1, IsAsync = false)]
    public Guid GetTaskID(string taskName)
    Parameters
    Type Name Description
    string taskName
    Returns
    Type Description
    Guid

    GetTaskParameter(string)

    Declaration
    [FormulaFunction(Name = "GetTaskParameter", Type = "Tasks", Description = "Returns the parameter class for settings paramaters for a specified task type.", Params = "1. The name of the server task type.", ParamCount = 1, IsAsync = false)]
    public SerializedParam GetTaskParameter(string taskName)
    Parameters
    Type Name Description
    string taskName
    Returns
    Type Description
    SerializedParam

    HasQueryResult(string, params string[])

    Executes the specified ISQLWrapper and returns true if there are any results

    Declaration
    [FormulaFunction(Name = "HasQueryResult", Type = "Queries", Description = "Returns True if there are any results when executing the SQLWrapper with the specified parameters.", Params = "1. The name of the query you want to return.\r\n2. param list of parameter name and value....", ParamCount = 2, IsAsync = true)]
    public Task<bool> HasQueryResult(string queryName, params string[] parameters)
    Parameters
    Type Name Description
    string queryName

    The name of the ISQLWrapper to execute

    string[] parameters

    Any parameters for executing the query in the form: @ParamName1=value1, @ParamName2=value2, ...

    Returns
    Type Description
    Task<bool>

    True if there are any results when executing the SQLWrapper with the specified parameters

    IsValid<T>(string)

    Validates the given formula against this context type. Throws an error with any compilation exceptions

    Declaration
    public bool IsValid<T>(string formula)
    Parameters
    Type Name Description
    string formula

    The formula, or script, to be parsed and evaluated

    Returns
    Type Description
    bool
    Type Parameters
    Name Description
    T

    the would-be return type of the formula or script

    See Also
    IScriptHelper

    IsValid<T>(string, Type)

    Validates the given formula against the provided contextType. Throws an error with any compilation exceptions

    Declaration
    public bool IsValid<T>(string formula, Type contextType)
    Parameters
    Type Name Description
    string formula

    The formula, or script, to be parsed and evaluated

    Type contextType

    The context object that can be referenced by the formula or script

    Returns
    Type Description
    bool
    Type Parameters
    Name Description
    T

    the would-be return type of the formula or script

    See Also
    IScriptHelper

    LogError(Exception, string, params object[])

    Logs an error message to the application log

    Declaration
    [FormulaFunction(Name = "LogError", Type = "Debugging", Description = "Logs an error message to the application log.", Params = "1. The error you want to log.\r\n2. The message, which can have tokens, for example: \"MyId: {Guid} | MyObject: {@Currency}.\". \r\nThe number of tokens must match the number of extra arguments.\r\nPutting an @ symbol inside the token {@Currency} will render out the entire object in the log.\r\n3. The arguments, which are a comma separated set of objects. There must be as many as there are tokens in the message.\r\nSo, give the message above, the call looks like this: LogError(new Exception(\"No item found!\"), \"MyId: {Guid} | MyObject: {@Currency}.\", someGuid, currency)", ParamCount = 3)]
    public void LogError(Exception error, string message, params object[] parameters)
    Parameters
    Type Name Description
    Exception error

    The exception

    string message

    The message to log

    object[] parameters

    The parameter array

    LogInfo(string, params object[])

    Logs a message to the application log

    Declaration
    [FormulaFunction(Name = "LogInfo", Type = "Debugging", Description = "Logs a message to the application log.", Params = "1. The message, which can have tokens, for example: \"MyId: {Guid} | MyObject: {@Currency}.\". \r\nThe number of tokens must match the number of extra arguments.\r\nPutting an @ symbol inside the token {@Currency} will render out the entire object in the log.\r\n2. The arguments, which are a comma separated set of objects. There must be as many as there are tokens in the message.\r\nSo, given the message above, the call looks like this: LogInfo(\"MyId: {Guid} | MyObject: {@Currency}.\", someGuid, currency)", ParamCount = 2)]
    public void LogInfo(string message, params object[] parameters)
    Parameters
    Type Name Description
    string message

    The message to log

    object[] parameters

    The parameter array

    RunDRQueryResult(string, params string[])

    Declaration
    public Task<DataRow[]> RunDRQueryResult(string queryName, params string[] parameters)
    Parameters
    Type Name Description
    string queryName
    string[] parameters
    Returns
    Type Description
    Task<DataRow[]>

    RunQuery(string, string, params string[])

    Executes the specified ISQLWrapper and returns the value of the specified column from the first result

    Declaration
    [FormulaFunction(Name = "RunQuery", Type = "Queries", Description = "Returns the result of the first row for a specified column of running the specified query.", Params = "1. The name of the query you want to return.\r\n2. The name of the column value to return\r\n3. param list of parameter name and value....", ParamCount = 3, IsAsync = true)]
    public Task<object> RunQuery(string queryName, string columnName, params string[] parameters)
    Parameters
    Type Name Description
    string queryName

    The name of the ISQLWrapper to execute

    string columnName

    The column Name in the SQLWrapper to return the value of

    string[] parameters

    Any parameters for executing the query in the form: @ParamName1=value1, @ParamName2=value2, ...

    Returns
    Type Description
    Task<object>

    The value of the specified column from the first result of executing the SQLWrapper

    RunQueryResult(string, params string[])

    Declaration
    [FormulaFunction(Name = "RunQueryResult", Type = "Queries", Description = "Returns an array of ISQLWrapperResult for running the specified query. Can be used with GetQueryResult to find all the values returned for all rows.", Params = "1. The name of the query you want to return.\r\n2. param list of parameter name and value....", ParamCount = 2, IsAsync = true)]
    public Task<ISQLWrapperResult[]> RunQueryResult(string queryName, params string[] parameters)
    Parameters
    Type Name Description
    string queryName
    string[] parameters
    Returns
    Type Description
    Task<ISQLWrapperResult[]>

    SetObjectValue(object, string, object)

    Declaration
    [FormulaFunction(Name = "SetObjectValue", Type = "Main", Description = "Set the value for the specified property for the specified item.", Params = "1. The item to update the property value of.\r\n2. The name of the property to update.\r\n3. The value to set the property to", ParamCount = 3, IsAsync = false)]
    public void SetObjectValue(object item, string propertyName, object value)
    Parameters
    Type Name Description
    object item
    string propertyName
    object value

    SetQueryRunnerHelper(Func<IEntityUpdater, ISQLWrapperInterpretor, Dictionary<string, string>, QueryableExecuter<ISQLWrapperResult>, Task<DataRow[]>>)

    Declaration
    public void SetQueryRunnerHelper(Func<IEntityUpdater, ISQLWrapperInterpretor, Dictionary<string, string>, QueryableExecuter<ISQLWrapperResult>, Task<DataRow[]>> queryRunner)
    Parameters
    Type Name Description
    Func<IEntityUpdater, ISQLWrapperInterpretor, Dictionary<string, string>, QueryableExecuter<ISQLWrapperResult>, Task<DataRow[]>> queryRunner

    ShareThisQueryCacheWithTarget(IFormulaFunctions)

    Declaration
    public virtual void ShareThisQueryCacheWithTarget(IFormulaFunctions targetContext)
    Parameters
    Type Name Description
    IFormulaFunctions targetContext

    TWR(string, string, string, string, params string[])

    Declaration
    [FormulaFunction(Name = "TWR", Type = "Queries", Description = "Executes the specified SQLWrapper gets all the specified date, values and cash flow deltas and then returns a calculated twr based on them", Params = "1. The name of the query to execute.\r\n2. The name of the column holding the date values\r\n3. The name of the column holding the value delta\r\n4. The name of the column holding the cashflow delta\r\n5. param list of parameter name and value....", ParamCount = 5, IsAsync = true)]
    public Task<decimal> TWR(string queryName, string dateColumn, string valueDeltaColumn, string cashFlowDeltaColumn, params string[] parameters)
    Parameters
    Type Name Description
    string queryName
    string dateColumn
    string valueDeltaColumn
    string cashFlowDeltaColumn
    string[] parameters
    Returns
    Type Description
    Task<decimal>

    TWRRow(string, string, string, string, params string[])

    Declaration
    [FormulaFunction(Name = "TWRRow", Type = "Queries", Description = "Executes the specified SQLWrapper gets all the specified date, values and cash flow deltas and then returns a calculated twr based on them", Params = "1. The name of the query to execute.\r\n2. The name of the column holding the date values\r\n3. The name of the column holding the cashflow type (TWRValueType)\r\n4. The name of the column holding the delta of type specified in 3\r\n5. param list of parameter name and value....", ParamCount = 5, IsAsync = true)]
    public Task<decimal> TWRRow(string queryName, string dateColumn, string valueDeltaColumn, string cashFlowDeltaColumn, params string[] parameters)
    Parameters
    Type Name Description
    string queryName
    string dateColumn
    string valueDeltaColumn
    string cashFlowDeltaColumn
    string[] parameters
    Returns
    Type Description
    Task<decimal>

    XIRR(string, string, string, params string[])

    Declaration
    [FormulaFunction(Name = "XIRR", Type = "Queries", Description = "Executes the specified SQLWrapper gets all the specified date and cash flow values and then returns a calculated xirr based on them", Params = "1. The name of the query to execute.\r\n2. The name of the column holding the date values\r\n3. The name of the column holding the cash flow values\r\n4. param list of parameter name and value....", ParamCount = 4, IsAsync = true)]
    public Task<decimal> XIRR(string queryName, string dateColumn, string cashColumn, params string[] parameters)
    Parameters
    Type Name Description
    string queryName
    string dateColumn
    string cashColumn
    string[] parameters
    Returns
    Type Description
    Task<decimal>

    XIRR(string, string, string, (string, object)[], params string[])

    Declaration
    [FormulaFunction(Name = "XIRR", Type = "Queries", Description = "Executes the specified SQLWrapper gets all the specified date and cash flow values (matching specified filters) and then returns a calculated xirr based on them", Params = "1. The name of the query to execute.\r\n2. The name of the column holding the date values\r\n3. The name of the column holding the cash flow values\r\n4. Array of (string ColName, object Value) holding values to filter the cashflow/date rows used.\r\n4. param list of parameter name and value....", ParamCount = 4, IsAsync = true)]
    public Task<decimal> XIRR(string queryName, string dateColumn, string cashColumn, (string, object)[] whereFilters, params string[] parameters)
    Parameters
    Type Name Description
    string queryName
    string dateColumn
    string cashColumn
    (string, object)[] whereFilters
    string[] parameters
    Returns
    Type Description
    Task<decimal>

    Implements

    IFormulaFunctions

    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

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