Table of Contents

Class UnpivotValues

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Translation-only marker for the typed UNPIVOT result projection. An instance of this type is the second parameter of the projection passed to the typed SQL Server Unpivot overload: projection: (t, v) => ... v.Name<string>("qtr") ... v.Value<decimal?>("val") ....

public sealed class UnpivotValues
Inheritance
UnpivotValues
Inherited Members
Extension Methods

Remarks

The marker carries no runtime state. It can also be instantiated and captured directly in an ordinary Select over an existing UNPIVOT source. Only the query translator may bind a Name<T>(string)/Value<T>(string) call; executing an accessor outside a query expression throws NotSupportedException.

The two role identifiers are resolved at runtime: they are not checked at compile time, so a missing role identifier or an incompatible explicit cell type can fail during query preparation or materialization rather than being rejected up front.

SQL Server UNPIVOT excludes a source cell whose value is NULL: the stacked result contains only non-null cells, so fewer rows than columns × source rows are expected. Declaring the value column non-nullable asserts only that the surviving cells are non-null; it does not change the exclusion.

Constructors

UnpivotValues()

Creates the marker. The constructor is public so a captured instance can be used in an ordinary Select projection; the instance itself has no behaviour.

public UnpivotValues()

Methods

Name<T>(string)

References the UNPIVOT name column (the output column that receives the originating source column name) with an explicit CLR type.

public T Name<T>(string nameColumn)

Parameters

nameColumn string

The raw name of the UNPIVOT name column (the FOR identifier). It is always safely quoted by the provider, regardless of the command's QuoteIdentifiers option, and is resolved at runtime.

Returns

T

The name value, materialized as T.

Type Parameters

T

The CLR type of the name column value.

Exceptions

NotSupportedException

Always thrown: the accessor is translation-only and can only be used inside a query expression.

Value<T>(string)

References the UNPIVOT value column (the output column that receives the stacked source column values) with an explicit CLR type.

public T Value<T>(string valueColumn)

Parameters

valueColumn string

The raw name of the UNPIVOT value column. It is always safely quoted by the provider, regardless of the command's QuoteIdentifiers option, and is resolved at runtime. Source cells whose value is NULL are excluded by SQL Server.

Returns

T

The value, materialized as T.

Type Parameters

T

The CLR type of the value column value.

Exceptions

NotSupportedException

Always thrown: the accessor is translation-only and can only be used inside a query expression.