Table of Contents

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 Expression
exprToFind Expression

Returns

Expression

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 Expression
context TContext
func Func<TContext, Expression, bool>

Returns

Expression

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 LambdaExpression
exprToReplaceParameter Expression

Returns

Expression

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 LambdaExpression
exprToReplaceParameter1 Expression
exprToReplaceParameter2 Expression

Returns

Expression

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 LambdaExpression
exprToReplaceParameter1 Expression
exprToReplaceParameter2 Expression
exprToReplaceParameter3 Expression

Returns

Expression

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 Expression

Expression-Tree which gets counted.

context TContext

Expression-Tree visitor context.

func Func<TContext, Expression, bool>

Predicate which is used to test if the given expression should be counted.

Returns

int

Type Parameters

TContext

GetDebugView(Expression)

Gets the DebugView internal property value of provided expression.

public static string GetDebugView(this Expression expression)

Parameters

expression Expression

Expression to get DebugView.

Returns

string

DebugView value.

GetMemberGetter(MemberInfo, Expression)

public static Expression GetMemberGetter(MemberInfo mi, Expression obj)

Parameters

mi MemberInfo
obj Expression

Returns

Expression

Replace(Expression, Expression, Expression)

public static Expression Replace(this Expression expression, Expression toReplace, Expression replacedBy)

Parameters

expression Expression
toReplace Expression
replacedBy Expression

Returns

Expression

Replace(Expression, Expression, Expression, IEqualityComparer<Expression>)

public static Expression Replace(this Expression expression, Expression toReplace, Expression replacedBy, IEqualityComparer<Expression> equalityComparer)

Parameters

expression Expression
toReplace Expression
replacedBy Expression
equalityComparer IEqualityComparer<Expression>

Returns

Expression

Transform(Expression?, Func<Expression, TransformInfo>)

public static Expression? Transform(this Expression? expr, Func<Expression, TransformInfo> func)

Parameters

expr Expression
func Func<Expression, TransformInfo>

Returns

Expression

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 Expression
func 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 Expression
context TContext
func Func<TContext, Expression, TransformInfo>

Returns

Expression

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 Expression
context TContext
func 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 Expression
context TContext
func 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 Expression
context TContext
func Func<TContext, Expression, bool>

Type Parameters

TContext