Class ExpressionHelper
Supports the calculations of expressions and summaries on an IEnumerable object. See the InitSummaryLibrary and InitFunctionLibrary methods to see the code for adding support for specific summaries and functions. Summaries are aggregation calculations applied to IEnumerable lists (e.g, StdDev), and functions are calculation applied to singular objects, usually members of an IEnumerable list (e.g, Cos).
Inheritance
Inherited Members
Namespace: Syncfusion.Olap.Engine.CalculationColumn
Assembly: Syncfusion.Olap.Base.dll
Syntax
public class ExpressionHelper
Constructors
ExpressionHelper()
Declaration
public ExpressionHelper()
Properties
CaseSensitive
Gets or sets a value indicating whether the case is considered while parsing formulas.
Declaration
public bool CaseSensitive { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Error
Gets the error result from the most recent calculation.
Declaration
public ExpressionError Error { get; }
Property Value
| Type |
|---|
| ExpressionError |
ErrorString
Gets the description of the most recent calculation.
Declaration
public string ErrorString { get; }
Property Value
| Type |
|---|
| System.String |
ListSeparator
Gets or sets the list separator.
Declaration
public static char ListSeparator { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Char | The list separator. |
QuoteMark
Gets or sets the quote mark.
Declaration
public static char QuoteMark { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Char | The quote mark. |
Methods
AddExpression(String, String)
Adds a visible expression column displaying the passed-in expression.
Declaration
public bool AddExpression(string name, string expression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The mapping name for the added column. |
| System.String | expression | The expression. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if a column was added. |
AddExpression(String, String, Boolean)
Adds an expression.
Declaration
public bool AddExpression(string name, string expression, bool showInGrid)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the expression. |
| System.String | expression | The expression. |
| System.Boolean | showInGrid | Indicates whether a visible column should be added to the underlying grid. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if expression was added. |
AddFunction(String, LambdaExpression)
Adds a function calculation.
Declaration
public bool AddFunction(string name, LambdaExpression exp)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the function. |
| System.Linq.Expressions.LambdaExpression | exp | The expression defining the function. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the function is added. |
AddNamedConstant(String, Object)
Adds the named constant.
Declaration
public void AddNamedConstant(string name, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Object | value | The value. |
AddSummary(String, LambdaExpression)
Adds a summary calculation to the SummaryLibrary.
Declaration
public bool AddSummary(string name, LambdaExpression exp)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the summary calculation. |
| System.Linq.Expressions.LambdaExpression | exp | LambdaExpression defining the summary calculation. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the summary was added. |
ChangeExpression(String, String)
Changes an expression.
Declaration
public bool ChangeExpression(string name, string expression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the expression to be changed. |
| System.String | expression | The expression. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the change was done. |
ChangeNamedConstant(String, Object)
Changes the named constant.
Declaration
public void ChangeNamedConstant(string name, object newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Object | newValue | The new value. |
Clear()
Clears all expressions.
Declaration
public bool Clear()
Returns
| Type | Description |
|---|---|
| System.Boolean | True if all the expressions are removed. |
ClearNamedConstants()
Clears the named constants.
Declaration
public void ClearNamedConstants()
ComputeCount(IEnumerable)
Returns the number of items in a given list.
Declaration
public static int ComputeCount(IEnumerable list)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | list | A list of items. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The number of items in the list. |
ComputeMaximum(IEnumerable)
Computes the maximum value in the given list.
Declaration
public static double ComputeMaximum(IEnumerable list)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | list | A list containing numeric values. |
Returns
| Type | Description |
|---|---|
| System.Double | The maximum value. |
ComputeMinimum(IEnumerable)
Computes the minimum value for a given list.
Declaration
public static double ComputeMinimum(IEnumerable list)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | list | A list of numeric values. |
Returns
| Type | Description |
|---|---|
| System.Double | The minimum value. |
ComputeStdDev(IEnumerable)
Returns the sample standard deviation of a list of values.
Declaration
public static double ComputeStdDev(IEnumerable list)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | list | The list of numeric values. |
Returns
| Type | Description |
|---|---|
| System.Double | The standard deviation of the list of numbers. |
ComputeSum(IEnumerable)
Computes the sum of the values in a given list.
Declaration
public static double ComputeSum(IEnumerable list)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | list | A list of numeric values. |
Returns
| Type | Description |
|---|---|
| System.Double | The sum. |
ComputeSummary(String, IEnumerable)
Computes a summary calculation.
Declaration
public object ComputeSummary(string summaryFormula, IEnumerable dataSource)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | summaryFormula | The summary formula. |
| System.Collections.IEnumerable | dataSource | The data source. |
Returns
| Type |
|---|
| System.Object |
GetComputedValue(ExpressionHelper, String, Object)
Gets the value of an expression for the given item.
Declaration
public static object GetComputedValue(ExpressionHelper helper, string expressionName, object item)
Parameters
| Type | Name | Description |
|---|---|---|
| ExpressionHelper | helper | The expression helper. |
| System.String | expressionName | The name of the expression. |
| System.Object | item | The item for which the expression is to be evaluated. |
Returns
| Type | Description |
|---|---|
| System.Object | The computed expression. |
InitFunctionLibrary()
Initializes the default function library.
Declaration
public virtual void InitFunctionLibrary()
InitSummaryLibrary()
Initializes the default summary library.
Declaration
public virtual void InitSummaryLibrary()
IsExpressionName(String)
Gets a value indicating whether the specified string is the name of an expression.
Declaration
public bool IsExpressionName(string expressionName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | expressionName | The name of the expression. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if there is an expression with this name. |
IsNamedConstant(String)
Determines whether the specified name is named constant.
Declaration
public bool IsNamedConstant(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
Returns
| Type |
|---|
| System.Boolean |
RemoveExpression(String)
Removes an expression.
Declaration
public bool RemoveExpression(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the expression to be removed. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the expression was removed. |
RemoveFunction(String, LambdaExpression)
Removes a function calculation.
Declaration
public bool RemoveFunction(string name, LambdaExpression exp)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the function. |
| System.Linq.Expressions.LambdaExpression | exp | The expression defining the function. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the function is removed. |
RemoveNamedConstant(String, Object)
Removes the named constant.
Declaration
public void RemoveNamedConstant(string name, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Object | value | The value. |
RemoveSummary(String, LambdaExpression)
Removes a summary from the summary library.
Declaration
public bool RemoveSummary(string name, LambdaExpression exp)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the expression to be removed. |
| System.Linq.Expressions.LambdaExpression | exp | The expression to be removed. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the removal was done. |