Class ExpressionExtensions
- Namespace
- LinqToDB.Expressions
- Assembly
- linq2db.dll
public static class ExpressionExtensions
- Inheritance
-
ExpressionExtensions
Methods
Find(Expression?, Expression)
Enumerates the expression tree and returns the exprToFind
if it's
contained within the expr
.
public static Expression? Find(this Expression? expr, Expression exprToFind)
Parameters
expr
ExpressionexprToFind
Expression
Returns
Find<TContext>(Expression?, TContext, Func<TContext, Expression, bool>)
Enumerates the given expr
and returns the first sub-expression
which matches the given func
. If no expression was found, null is returned.
public static Expression? Find<TContext>(this Expression? expr, TContext context, Func<TContext, Expression, bool> func)
Parameters
expr
Expressioncontext
TContextfunc
Func<TContext, Expression, bool>
Returns
Type Parameters
TContext
GetBody(LambdaExpression, Expression)
Returns the body of lambda
but replaces the first parameter of that
lambda expression with the exprToReplaceParameter
expression.
public static Expression GetBody(this LambdaExpression lambda, Expression exprToReplaceParameter)
Parameters
lambda
LambdaExpressionexprToReplaceParameter
Expression
Returns
GetBody(LambdaExpression, Expression, Expression)
Returns the body of lambda
but replaces the first two parameters of
that lambda expression with the given replace expressions.
public static Expression GetBody(this LambdaExpression lambda, Expression exprToReplaceParameter1, Expression exprToReplaceParameter2)
Parameters
lambda
LambdaExpressionexprToReplaceParameter1
ExpressionexprToReplaceParameter2
Expression
Returns
GetBody(LambdaExpression, Expression, Expression, Expression)
Returns the body of lambda
but replaces the first three parameters of
that lambda expression with the given replace expressions.
public static Expression GetBody(this LambdaExpression lambda, Expression exprToReplaceParameter1, Expression exprToReplaceParameter2, Expression exprToReplaceParameter3)
Parameters
lambda
LambdaExpressionexprToReplaceParameter1
ExpressionexprToReplaceParameter2
ExpressionexprToReplaceParameter3
Expression
Returns
GetCount<TContext>(Expression, TContext, Func<TContext, Expression, bool>)
Returns the total number of expression items which are matching the given.
func
.
public static int GetCount<TContext>(this Expression expr, TContext context, Func<TContext, Expression, bool> func)
Parameters
expr
ExpressionExpression-Tree which gets counted.
context
TContextExpression-Tree visitor context.
func
Func<TContext, Expression, bool>Predicate which is used to test if the given expression should be counted.
Returns
Type Parameters
TContext
GetDebugView(Expression)
Gets the DebugView internal property value of provided expression.
public static string GetDebugView(this Expression expression)
Parameters
expression
ExpressionExpression to get DebugView.
Returns
- string
DebugView value.
GetMemberGetter(MemberInfo, Expression)
public static Expression GetMemberGetter(MemberInfo mi, Expression obj)
Parameters
mi
MemberInfoobj
Expression
Returns
Replace(Expression, Expression, Expression)
public static Expression Replace(this Expression expression, Expression toReplace, Expression replacedBy)
Parameters
expression
ExpressiontoReplace
ExpressionreplacedBy
Expression
Returns
Replace(Expression, Expression, Expression, IEqualityComparer<Expression>)
public static Expression Replace(this Expression expression, Expression toReplace, Expression replacedBy, IEqualityComparer<Expression> equalityComparer)
Parameters
expression
ExpressiontoReplace
ExpressionreplacedBy
ExpressionequalityComparer
IEqualityComparer<Expression>
Returns
Transform(Expression?, Func<Expression, TransformInfo>)
public static Expression? Transform(this Expression? expr, Func<Expression, TransformInfo> func)
Parameters
expr
Expressionfunc
Func<Expression, TransformInfo>
Returns
Transform(Expression?, Func<Expression, Expression>)
Enumerates the expression tree of expr
and might
replace expression with the returned value of the given func
.
public static Expression? Transform(this Expression? expr, Func<Expression, Expression> func)
Parameters
expr
Expressionfunc
Func<Expression, Expression>
Returns
- Expression
The modified expression.
Transform<TContext>(Expression?, TContext, Func<TContext, Expression, TransformInfo>)
public static Expression? Transform<TContext>(this Expression? expr, TContext context, Func<TContext, Expression, TransformInfo> func)
Parameters
expr
Expressioncontext
TContextfunc
Func<TContext, Expression, TransformInfo>
Returns
Type Parameters
TContext
Transform<TContext>(Expression?, TContext, Func<TContext, Expression, Expression>)
Enumerates the expression tree of expr
and might
replace expression with the returned value of the given func
.
public static Expression? Transform<TContext>(this Expression? expr, TContext context, Func<TContext, Expression, Expression> func)
Parameters
expr
Expressioncontext
TContextfunc
Func<TContext, Expression, Expression>
Returns
- Expression
The modified expression.
Type Parameters
TContext
Visit<TContext>(Expression, TContext, Action<TContext, Expression>)
Calls the given func
for each child node of the expr
.
public static void Visit<TContext>(this Expression expr, TContext context, Action<TContext, Expression> func)
Parameters
expr
Expressioncontext
TContextfunc
Action<TContext, Expression>
Type Parameters
TContext
Visit<TContext>(Expression, TContext, Func<TContext, Expression, bool>)
Calls the given func
for each node of the expr
.
If the func
returns false, no childs of the tested expression will be enumerated.
public static void Visit<TContext>(this Expression expr, TContext context, Func<TContext, Expression, bool> func)
Parameters
expr
Expressioncontext
TContextfunc
Func<TContext, Expression, bool>
Type Parameters
TContext