Show / Hide Table of Contents

Class ExpressionExtensions

Static wrapper for methods on Expression nodes. You should never have to refer to this class directly.

Inheritance
Object
ExpressionExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Mangrove.MetricSetTransformers.Extensions
Assembly: MetricSetTransformers.dll
Syntax
public static class ExpressionExtensions

Methods

View Source

IsAverage(ColumnReference)

Declaration
public static bool IsAverage(ColumnReference cr)
Parameters
Type Name Description
ColumnReference cr
Returns
Type Description
Boolean
View Source

IsPercentile(ColumnReference)

Declaration
public static bool IsPercentile(ColumnReference cr)
Parameters
Type Name Description
ColumnReference cr
Returns
Type Description
Boolean
View Source

IsVR(ColumnReference)

Declaration
public static bool IsVR(ColumnReference cr)
Parameters
Type Name Description
ColumnReference cr
Returns
Type Description
Boolean
View Source

IsWavg(ColumnReference)

Declaration
public static bool IsWavg(ColumnReference cr)
Parameters
Type Name Description
ColumnReference cr
Returns
Type Description
Boolean
View Source

Names(IEnumerable<ColumnReference>)

The sequence of ColumnNames from this collection.

Declaration
public static IEnumerable<string> Names(this IEnumerable<ColumnReference> columnReferences)
Parameters
Type Name Description
IEnumerable<ColumnReference> columnReferences
Returns
Type Description
IEnumerable<String>
View Source

NeedsColumnReferenceWrap(Expression)

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
Type Name Description
Expression expr
Returns
Type Description
Boolean
View Source

References(Expression, ISet<Table>)

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
Type Name Description
Expression expr
ISet<Table> tables
Returns
Type Description
Boolean
Remarks

If expr has no parents, the method returns false.

View Source

TopParentsOfType<TParent>(Expression)

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
Type Name Description
Expression node
Returns
Type Description
ISet<TParent>
Type Parameters
Name Description
TParent
View Source

Unwrap(Expression, Boolean)

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
Type Name Description
Expression expr
Boolean unwrapTables

Whether or not to 'unwrap' ColumnReference nodes that stretch across TableReference dependencies.

Returns
Type Description
Expression
View Source

UnwrapParentheses(Expression)

Unwrap Parentheses nodes only, this is needed as a separate method because Unwrap(Expression, Boolean) unwraps both Parentheses and ColumnReference nodes.

Declaration
public static Expression UnwrapParentheses(this Expression expr)
Parameters
Type Name Description
Expression expr
Returns
Type Description
Expression
View Source

WrapName(Expression, String)

Declaration
public static ColumnReference WrapName(this Expression expr, string name)
Parameters
Type Name Description
Expression expr
String name
Returns
Type Description
ColumnReference
View Source

WrapUniqueName(Expression, String)

Declaration
public static ColumnReference WrapUniqueName(this Expression expr, string prefix = "")
Parameters
Type Name Description
Expression expr
String prefix
Returns
Type Description
ColumnReference
  • View Source
Back to top Generated by DocFX