Table of Contents

Class WindowFunction<T>

Namespace
NextORM.Core
Assembly
nextorm.core.dll

A window-function call that has not been given its OVER clause yet. The row_number, rank, lag, sum_over, ... methods of CommonFunctions return this wrapper so that Over(Expression<Func<object?>>?, Expression<Func<object?>>?, WindowFrame?) can be chained and returns the value type that is actually read from the result set.

The wrapper is only ever produced by the compiler while building an expression tree; none of its members is executed. The nested partitionBy/orderBy lambdas close over the outer query parameter, e.g. SqlFunctions.Sql.row_number().Over(partitionBy: () => e.Int, orderBy: () => e.Id).

public sealed class WindowFunction<T>

Type Parameters

T
Inheritance
WindowFunction<T>
Inherited Members
Extension Methods

Methods

Over(WindowOrder, WindowFrame?)

Completes the window function with a single ordered key and an optional frame.

public T Over(WindowOrder orderBy, WindowFrame? frame = null)

Parameters

orderBy WindowOrder
frame WindowFrame

Returns

T

Over(WindowOrder[], WindowFrame?)

Completes the window function with multiple ordered keys. Use this when a mixed asc/desc ordering or more than one order key is required; partition keys for this shape are supplied through the array overload (see the Over overload below).

public T Over(WindowOrder[] orderBy, WindowFrame? frame = null)

Parameters

orderBy WindowOrder[]
frame WindowFrame

Returns

T

Over(Expression<Func<object?>>?, WindowOrder, WindowFrame?)

Completes the window function with a single partition expression and a single ordered key (asc/desc), plus an optional frame. This is the scalar counterpart of the array overload below for callers that do not build arrays.

The overload is declared with OverloadResolutionPriorityAttribute priority -1 so that the existing Over(Expression<Func<object?>>?, Expression<Func<object?>>?, WindowFrame?) overload wins whenever it is applicable. Without that, an untyped default or null in the orderBy position (for example Over(partitionBy: e, orderBy: default)) would be ambiguous between the two overloads and would stop compiling; the attribute only orders resolution, the signature itself is additive.

public T Over(Expression<Func<object?>>? partitionBy, WindowOrder orderBy, WindowFrame? frame = null)

Parameters

partitionBy Expression<Func<object>>

The partition key expression (a lambda closing over the outer query parameter), or null for no PARTITION BY.

orderBy WindowOrder

The single ordered key of the window.

frame WindowFrame

An optional ROWS/RANGE/GROUPS frame.

Returns

T

Over(Expression<Func<object?>>?, Expression<Func<object?>>?, WindowFrame?)

Completes the window function with a partition and/or an ascending ORDER BY plus an optional frame. Over() renders an empty specification (over ()); trailing arguments may be omitted.

Because C# expression trees reject named arguments that skip a preceding defaulted parameter, an order-only specification must use the WindowOrder overloads (Over(SqlFunctions.Sql.asc(() => e.Id))) rather than Over(orderBy: ...).

public T Over(Expression<Func<object?>>? partitionBy = null, Expression<Func<object?>>? orderBy = null, WindowFrame? frame = null)

Parameters

partitionBy Expression<Func<object>>
orderBy Expression<Func<object>>
frame WindowFrame

Returns

T

Over(Expression<Func<object?>>[]?, WindowOrder[]?, WindowFrame?)

Completes the window function with multiple partition and/or ordered expressions, allowing a mixed asc/desc ordering built with asc(Expression<Func<object?>>) and desc(Expression<Func<object?>>). partitionBy is required here so that Over() still binds unambiguously to the single-expression overload.

public T Over(Expression<Func<object?>>[]? partitionBy, WindowOrder[]? orderBy = null, WindowFrame? frame = null)

Parameters

partitionBy Expression<Func<object>>[]
orderBy WindowOrder[]
frame WindowFrame

Returns

T

Over(string)

Completes the window function by referencing a named window declared on the query with EntityBuilder.Window(...) (rendered as OVER windowName). Requires a dialect that supports the WINDOW clause (see SupportsNamedWindows).

public T Over(string windowName)

Parameters

windowName string

The name of a window declared on the same query.

Returns

T