Table of Contents

Class TvfEntityBuilder<T>

Namespace
NextORM.Core
Assembly
nextorm.core.dll

A context-independent runtime descriptor of a table-valued function used as a query source.

A TVF factory is an ordinary static method that returns this descriptor, for example public static TvfEntityBuilder<Row> MyTvf(int id) => new("my_tvf", "dbo");. The scalar parameters of the factory only name the argument positions of the call expression; the metadata (name, schema, clauses, verbatim index list, result schema) must not depend on the argument values. The arguments themselves stay in the caller's expression tree and are lowered when the descriptor is consumed by IDataContext.From/Join/APPLY, so a correlated argument is never evaluated as a CLR value.

The descriptor carries no data context and never gets one written into it: composing Where/OrderBy and the other builder operators clones an unbound chain that fails explicitly on any context-dependent operation until it is bound by the context that consumes it. Metadata is constructor-only and immutable; the verbatim index list is defensively copied.

public class TvfEntityBuilder<T> : EntityBuilder<T>, ICloneable

Type Parameters

T

The mapped row type the function returns.

Inheritance
TvfEntityBuilder<T>
Implements
Inherited Members
Extension Methods

Constructors

TvfEntityBuilder(string)

Creates a descriptor for a table-valued function without a schema.

public TvfEntityBuilder(string name)

Parameters

name string

The SQL function name.

Exceptions

ArgumentNullException

name is null.

ArgumentException

name is empty or whitespace.

TvfEntityBuilder(string, string?)

Creates a descriptor for a table-valued function in an optional schema.

public TvfEntityBuilder(string name, string? schema)

Parameters

name string

The SQL function name.

schema string

Optional schema/owner name; null renders the bare name.

Exceptions

ArgumentNullException

name is null.

ArgumentException

name is empty or whitespace.

TvfEntityBuilder(string, string?, string?, string?, IReadOnlyList<int>, TableFunctionSchema)

Creates a descriptor with the full runtime metadata of the function.

public TvfEntityBuilder(string name, string? schema, string? withClause, string? callClause, IReadOnlyList<int> verbatimArguments, TableFunctionSchema resultSchema)

Parameters

name string

The SQL function name.

schema string

Optional schema/owner name; null renders the bare name.

withClause string

Optional trailing WITH (...) clause body appended after the call.

callClause string

Optional verbatim SQL appended inside the call parentheses after the arguments.

verbatimArguments IReadOnlyList<int>

Indices of the arguments emitted verbatim as SQL (identifiers, not parameters); an empty list means every argument is a value. The list is defensively copied and must contain distinct, non-negative indices. It is never null: "no verbatim argument" is expressed by an empty list.

resultSchema TableFunctionSchema

Where the caller-declared result schema is rendered.

Exceptions

ArgumentNullException

name or verbatimArguments is null.

ArgumentException

name is empty or whitespace, or verbatimArguments contains a negative or duplicate index.

Properties

CallClause

Optional verbatim SQL appended inside the call parentheses after the arguments.

public string? CallClause { get; }

Property Value

string

Name

The SQL function name.

public string Name { get; }

Property Value

string

ResultSchema

Where the caller-declared result schema is rendered.

public TableFunctionSchema ResultSchema { get; }

Property Value

TableFunctionSchema

Schema

Optional schema/owner prefix rendered as schema.name.

public string? Schema { get; }

Property Value

string

VerbatimArguments

The argument indices emitted verbatim as SQL; empty when every argument is a parameterised value.

public IReadOnlyList<int> VerbatimArguments { get; }

Property Value

IReadOnlyList<int>

WithClause

Optional trailing WITH (...) clause body appended after the call.

public string? WithClause { get; }

Property Value

string

Methods

CloneImp()

Clones the unbound descriptor, preserving its runtime metadata. Unlike a context-bound builder clone this copy needs no data context, so Where/OrderBy composition on a descriptor never touches a context.

protected override object CloneImp()

Returns

object

A descriptor with the same metadata and composition state.