Table of Contents

Class SqlAggregateLifterExpression

Namespace
LinqToDB.Internal.Expressions
Assembly
linq2db.dll

Wraps a SqlPlaceholderExpression produced by an aggregate-function translator and carries up to two delegates that customize how the placeholder is processed at later phases of query building:

  • MaterializationCheck — invoked at C# materialization time. Used by non-nullable Min/Max/Avg to wrap the column read with a runtime CheckNullValue call that throws on NULL.
  • SqlRewriter — invoked at OUTER APPLY lift time (in AggregateExecuteContext.CreateWeakOuterJoin) after UpdateNesting has promoted the inner aggregate to a parent-side column reference, or eagerly for grouped aggregates. Used by non-nullable Sum and StringJoin-family aggregates to wrap the lifted column reference with COALESCE(<ref>, default). The bare aggregate stays in the inner SQL tree during provider validation/ optimization.

At least one of the two delegates is set. Both can be set when an aggregate needs runtime null-check AND late SQL coalesce wrapping; in that case, the conceptual order is: SqlRewriter runs at lift time, then MaterializationCheck at materialization. CanReduce returns false — neither delegate is auto-invoked by visitor reduction; consumers explicitly invoke them at the right hook point.

public sealed class SqlAggregateLifterExpression : Expression
Inheritance
object
SqlAggregateLifterExpression
Inherited Members
Extension Methods

Constructors

SqlAggregateLifterExpression(Expression, Func<Expression, Expression>?, Func<SqlPlaceholderExpression, SqlPlaceholderExpression>?)

public SqlAggregateLifterExpression(Expression inner, Func<Expression, Expression>? materializationCheck = null, Func<SqlPlaceholderExpression, SqlPlaceholderExpression>? sqlRewriter = null)

Parameters

inner Expression
materializationCheck Func<Expression, Expression>
sqlRewriter Func<SqlPlaceholderExpression, SqlPlaceholderExpression>

Properties

CanReduce

Indicates that the node can be reduced to a simpler node. If this returns true, Reduce() can be called to produce the reduced form.

public override bool CanReduce { get; }

Property Value

bool

True if the node can be reduced, otherwise false.

InnerExpression

public Expression InnerExpression { get; }

Property Value

Expression

MaterializationCheck

public Func<Expression, Expression>? MaterializationCheck { get; }

Property Value

Func<Expression, Expression>

NodeType

Gets the node type of this Expression.

public override ExpressionType NodeType { get; }

Property Value

ExpressionType

One of the ExpressionType values.

SqlRewriter

public Func<SqlPlaceholderExpression, SqlPlaceholderExpression>? SqlRewriter { get; }

Property Value

Func<SqlPlaceholderExpression, SqlPlaceholderExpression>

Type

Gets the static type of the expression that this Expression represents.

public override Type Type { get; }

Property Value

Type

The Type that represents the static type of the expression.

Methods

Accept(ExpressionVisitor)

Dispatches to the specific visit method for this node type. For example, MethodCallExpression calls the VisitMethodCall(MethodCallExpression).

protected override Expression Accept(ExpressionVisitor visitor)

Parameters

visitor ExpressionVisitor

The visitor to visit this node with.

Returns

Expression

The result of visiting this node.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a textual representation of the Expression.

public override string ToString()

Returns

string

A textual representation of the Expression.

Update(Expression)

public SqlAggregateLifterExpression Update(Expression innerExpression)

Parameters

innerExpression Expression

Returns

SqlAggregateLifterExpression