ExpressionExtensions

Ecng.Linq

The extensions for Expression.

Методы

EnumerateSources
public static IQueryable[] EnumerateSources(Expression expression)
result = ExpressionExtensions.EnumerateSources(expression)

Lists every queryable source names: the one it is composed over plus any a join or a sub-query brings in.

expression
The composed query.

Возвращает: The distinct sources, in the order they appear.

Evaluate
public static object Evaluate(Expression e)
result = ExpressionExtensions.Evaluate(e)

Evaluates the expression and returns its value.

e
The expression to evaluate.

Возвращает: The evaluated value.

GetConstant``1
public static T GetConstant<T>(Expression e)
result = ExpressionExtensions.GetConstant(e)

Gets the constant value from the expression.

e
The expression.

Возвращает: The constant value.

GetInnerMember
public static MemberExpression GetInnerMember(MemberExpression exp)
result = ExpressionExtensions.GetInnerMember(exp)

Retrieves the innermost member in a nested member expression.

exp
The member expression to process.

Возвращает: The innermost member expression.

GetMemberValue
public static object GetMemberValue(MemberInfo member, object instance)
result = ExpressionExtensions.GetMemberValue(member, instance)

Gets the value of the specified member from the given instance.

member
The member whose value to retrieve.
instance
The object instance from which to retrieve the value.

Возвращает: The value of the member.

GetValue``1
public static TValue GetValue<TValue>(Expression exp)
result = ExpressionExtensions.GetValue(exp)

Evaluates the expression and returns its value as the specified type.

exp
The expression to evaluate.

Возвращает: The evaluated value converted to the specified type.

PinSources
public static Expression PinSources(Expression expression, IQueryable[] sources)
result = ExpressionExtensions.PinSources(expression, sources)

Rebuilds so that every source it names is held in place, and reports the sources found.

expression
The composed query.
sources
The distinct sources, in the order they appear.

Возвращает: The rebuilt expression, naming each source directly.

ReplaceRootSource
public static Expression ReplaceRootSource(Expression expression, IQueryable source)
result = ExpressionExtensions.ReplaceRootSource(expression, source)

Rebuilds over another source, so a query composed against one queryable runs against another.

expression
The composed query, e.g. a Where over a table.
source
The source to run it over instead, e.g. the same table held in memory.

Возвращает: The rebuilt expression, or when it has no queryable root.

ReplaceSource
public static void ReplaceSource(Expression expression, IQueryProvider provider)
ExpressionExtensions.ReplaceSource(expression, provider)

Replaces the source provider in the expression with the specified query provider.

expression
The expression to modify.
provider
The query provider to set.
ReplaceSources
public static Expression ReplaceSources(Expression expression, IReadOnlyDictionary<object, IQueryable> sources)
result = ExpressionExtensions.ReplaceSources(expression, sources)

Rebuilds with each source it names replaced by the one mapped to it, so a query composed over database tables runs over held copies of them instead.

expression
The composed query.
sources
What to put in place of each source.

Возвращает: The rebuilt expression.

StripQuotes
public static Expression StripQuotes(Expression e)
result = ExpressionExtensions.StripQuotes(e)

Removes quote expressions from the given expression.

e
The expression to process.

Возвращает: The unquoted expression.

ToOperator
public static ComparisonOperator ToOperator(ExpressionType type)
result = ExpressionExtensions.ToOperator(type)

Converts the given expression type to its equivalent ComparisonOperator.

type
The expression type.

Возвращает: The corresponding ComparisonOperator.