Class TvfEntityBuilder<T>
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
TThe 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
namestringThe SQL function name.
Exceptions
- ArgumentNullException
nameis null.- ArgumentException
nameis 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
namestringThe SQL function name.
schemastringOptional schema/owner name; null renders the bare name.
Exceptions
- ArgumentNullException
nameis null.- ArgumentException
nameis 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
namestringThe SQL function name.
schemastringOptional schema/owner name; null renders the bare name.
withClausestringOptional trailing
WITH (...)clause body appended after the call.callClausestringOptional verbatim SQL appended inside the call parentheses after the arguments.
verbatimArgumentsIReadOnlyList<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.
resultSchemaTableFunctionSchemaWhere the caller-declared result schema is rendered.
Exceptions
- ArgumentNullException
nameorverbatimArgumentsis null.- ArgumentException
nameis empty or whitespace, orverbatimArgumentscontains a negative or duplicate index.
Properties
CallClause
Optional verbatim SQL appended inside the call parentheses after the arguments.
public string? CallClause { get; }
Property Value
Name
The SQL function name.
public string Name { get; }
Property Value
ResultSchema
Where the caller-declared result schema is rendered.
public TableFunctionSchema ResultSchema { get; }
Property Value
Schema
Optional schema/owner prefix rendered as schema.name.
public string? Schema { get; }
Property Value
VerbatimArguments
The argument indices emitted verbatim as SQL; empty when every argument is a parameterised value.
public IReadOnlyList<int> VerbatimArguments { get; }
Property Value
WithClause
Optional trailing WITH (...) clause body appended after the call.
public string? WithClause { get; }
Property Value
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.