Table of Contents

Class ExtremeRowComponent<TEntity>

Namespace
NextORM.Extensions
Assembly
nextorm.extensions.dll

The public query component behind SelectWhereMin<TEntity, TValue>(EntityBuilder<TEntity>, Expression<Func<TEntity, TValue>>, ExtremeRowTies, Expression<Func<TEntity, object?>>?) and its siblings: an exclusive row-source reshape that keeps the extreme row(s). The extension methods construct and attach it; a caller that needs the component directly passes ExtremeKind explicitly.

public sealed class ExtremeRowComponent<TEntity> : IQueryComponent, IQueryComponentShape

Type Parameters

TEntity

The mapped entity type the selectors are written over.

Inheritance
ExtremeRowComponent<TEntity>
Implements
Inherited Members
Extension Methods

Constructors

ExtremeRowComponent(ExtremeKind, LambdaExpression, ExtremeRowTies, Expression<Func<TEntity, object?>>?)

Creates the component for one direction and one selection state.

public ExtremeRowComponent(ExtremeKind kind, LambdaExpression valueSelector, ExtremeRowTies ties, Expression<Func<TEntity, object?>>? groupBy)

Parameters

kind ExtremeKind

Whether the component keeps the minimum or the maximum value.

valueSelector LambdaExpression

The value selector; its single parameter must be typed TEntity.

ties ExtremeRowTies

Whether to keep one row or every tied row.

groupBy Expression<Func<TEntity, object>>

Optional grouping key; null selects across the whole source.

Exceptions

ArgumentNullException

valueSelector is null.

ArgumentException

valueSelector is not a single-parameter lambda over TEntity.

Properties

Contribution

The contribution kind: the component replaces the row source, so only one exclusive reshape may be present.

public QueryComponentContribution Contribution { get; }

Property Value

QueryComponentContribution

ShapeSelectorCount

The selector count: the value selector, plus the group key when one is present.

public int ShapeSelectorCount { get; }

Property Value

int

ShapeSelectors

Cached shape selectors.

public LambdaExpression[] ShapeSelectors { get; }

Property Value

LambdaExpression[]

ShapeState

The scalar half of the pre-preparation structural identity used by the engine's raw recipe cache: the direction and the tie policy. Selectors travel through GetShapeSelector(int).

public object? ShapeState { get; }

Property Value

object

Slot

The component slot: one stable slot per entity type, so a second extreme-row call replaces this component in place.

public Type Slot { get; }

Property Value

Type

Methods

BuildQuery(IQueryComponentBuildContext)

Builds the component's structural contribution into the command. Runs on a plan-cache miss only: One becomes a ranked derived source filtered on rank 1. Under All, floating value keys and nullable group keys on dialects whose public capabilities indicate risky join semantics use the rank window; other cases use aggregate+join.

public void BuildQuery(IQueryComponentBuildContext context)

Parameters

context IQueryComponentBuildContext

The command being built and the engine expression comparer.

Exceptions

ArgumentNullException

context is null.

GetShapeSelector(int)

Returns the value selector (index 0) or the group key (index 1).

public LambdaExpression GetShapeSelector(int index)

Parameters

index int

Zero-based selector index.

Returns

LambdaExpression

The selector expression.

Exceptions

ArgumentOutOfRangeException

The index is outside ShapeSelectorCount.

Prepare(IQueryComponentPrepareContext)

Validates the component against the command and returns the immutable descriptor that joins the plan key: the direction, the tie policy and both selectors, compared with the engine's expression comparer. Preparation is also where the in-memory provider and the unsupported modifiers are rejected.

public IQueryComponentDescriptor Prepare(IQueryComponentPrepareContext context)

Parameters

context IQueryComponentPrepareContext

The command being prepared and the engine expression comparer.

Returns

IQueryComponentDescriptor

The component's structural descriptor.

Exceptions

ArgumentNullException

context is null.

NotSupportedException

The command targets the in-memory provider.

ArgumentOutOfRangeException

The tie policy is not One or All.

BuildSqlCommandException

The command carries a modifier the reshape cannot express.