Class ExpressionExtensions
Static wrapper for methods on Expression nodes. You
should never have to refer to this class directly.
Inheritance
ExpressionExtensions
Assembly: MetricSetTransformers.dll
public static class ExpressionExtensions
Methods
View Source
Declaration
public static bool IsAverage(ColumnReference cr)
Parameters
Returns
View Source
Declaration
public static bool IsPercentile(ColumnReference cr)
Parameters
Returns
View Source
Declaration
public static bool IsVR(ColumnReference cr)
Parameters
Returns
View Source
Declaration
public static bool IsWavg(ColumnReference cr)
Parameters
Returns
View Source
Declaration
public static IEnumerable<string> Names(this IEnumerable<ColumnReference> columnReferences)
Parameters
Returns
View Source
An expression needs to be wrapped into a ColumnReference if
it's not itself a ColumnReference, and if at least one of its
top ColumnReference parents lives in a different table.
The logic is: an expression doesn't need a wrap if it could be inlined
in the table above and still give a correct code.
For example, expression x+y
does not need a wrap if both x and y are on the same table,
because it's OK to inline it in a table above (e.g. it's OK to write AVG(x+y)
).
At the same time, if one of x or y was from a different table, it would need to be wrapped.
Another example. An expression AVG(x)
needs to be wrapped, because its
top ColumnReference x
is from a different table. And indeed,
we cannot inline this expression, i.e. AVG(AVG(x)) will not produce valid select statement.
Note: any non-ColumnReference expression on DataSource columns needs to be wrapped.
Declaration
public static bool NeedsColumnReferenceWrap(this Expression expr)
Parameters
Returns
View Source
Check if the expression expr
's parents belong
to one of the tables
.
Declaration
public static bool References(this Expression expr, ISet<Table> tables)
Parameters
Returns
View Source
Set of closest parents of Expression node
which are of of type TParent
.
Declaration
public static ISet<TParent> TopParentsOfType<TParent>(this Expression node)
where TParent : Expression<TParent, Table>
Parameters
Returns
Type |
Description |
ISet<TParent> |
|
Type Parameters
View Source
Given a chain of ColumnReference or 'parenthesis' nodes:
cr1 -> cr2 -> cr3 -> ... crN, return back the last one.
Declaration
public static Expression Unwrap(this Expression expr, bool unwrapTables = false)
Parameters
Returns
View Source
Declaration
public static Expression UnwrapParentheses(this Expression expr)
Parameters
Returns
View Source
Declaration
public static ColumnReference WrapName(this Expression expr, string name)
Parameters
Returns
View Source
Declaration
public static ColumnReference WrapUniqueName(this Expression expr, string prefix = "")
Parameters
Returns