Class TableParameterValue
The value of a table-valued parameter: a sequence of rows plus the CLR type of each row. It is held
by Value and never bound by the provider directly — each provider's
CreateProcedureParameter hook translates it (SQL Server streams SqlDataRecords, other
providers pass a JSON document or a typed array).
A row type is either a scalar (a primitive, string, decimal,
Guid, DateTime/DateTimeOffset/DateOnly/
TimeOnly, TimeSpan, byte[], an enum or a nullable of these)
mapping to one column, or a
mapped entity whose columns come from the entity metadata (every non-computed mapped
property, in metadata order, including identity columns; use the same [SqlTable]/fluent
mapping as a bulk insert). A Range<T> property (two columns) is not supported.
The type is not user-extensible: the constructor is private protected and instances are
created only through the ProcedureParameter.Table<T> factories. The rows are enumerated
once per provider enumeration; do not mutate or dispose the source between building the descriptor and
executing the command.
public abstract class TableParameterValue
- Inheritance
-
TableParameterValue
- Inherited Members
- Extension Methods
Properties
Count
The number of rows when the source sequence is a known-size collection (ICollection<T>/IReadOnlyCollection<T>), or null for a lazy/one-shot source. Providers use it to bind an empty table-valued parameter without consuming the sequence.
public int? Count { get; }
Property Value
- int?
IsScalar
Whether the row type maps to a single column (a scalar) rather than to a mapped entity. A scalar
set has one synthetic column named Value.
public bool IsScalar { get; }
Property Value
RowType
The CLR type of each row (the entity type or the scalar element type).
public Type RowType { get; }
Property Value
Rows
The rows, boxed. Providers enumerate this; a fresh enumeration is created per GetEnumerator() call when the underlying source supports it.
public abstract IEnumerable<object> Rows { get; }
Property Value
Methods
GetColumns(DataContext)
Resolves the columns bound by the provider: one synthetic Value column for a scalar row
type, or the entity's non-computed mapped columns (in metadata order, including identity columns)
for an entity. The column's CLR type is the converter's provider type when a value converter is
mapped, an enum is exposed as its underlying numeric type and, on a provider without a native
duration type, a TimeSpan as the integer type it is stored as.
public IReadOnlyList<TableParameterColumn> GetColumns(DataContext context)
Parameters
contextDataContextThe context supplying the naming convention and dialect.
Returns
- IReadOnlyList<TableParameterColumn>
The columns, in binding order.
Exceptions
- NotSupportedException
A property maps a Range<T> to two columns, the entity has no mapped column, or a property maps through a value converter to TimeSpan on a provider without a native duration type.
- InvalidOperationException
A column declares a decimal precision/scale whose bound provider type is not decimal, or as a partial pair.
- ArgumentOutOfRangeException
A column declares a decimal precision/scale outside the allowed range (precision 1..38, scale 0..precision).
ToArray(DataContext)
Builds a typed one-dimensional array from a scalar table-valued parameter, for a provider that binds a scalar set as a native array (PostgreSQL, ClickHouse). The element type is the row type's provider storage type: a sbyte widens to short, ushort to int, uint to long, ulong to decimal and char to string; an enum is its underlying number and, on a provider without a native duration type, a TimeSpan is its integer storage value (the same representation the entity path binds). Nullability mirrors the row type: a nullable row type produces a nullable element array so NULL rows survive, a non-nullable one a non-nullable array. Intended for a scalar row type only.
public Array ToArray(DataContext context)
Parameters
contextDataContextThe context supplying the dialect.
Returns
- Array
The typed array.
WriteJson(DataContext)
Serializes the parameter as a JSON array and returns the UTF-8 document as a string.
public string WriteJson(DataContext context)
Parameters
contextDataContextThe context supplying the naming convention and dialect.
Returns
- string
The UTF-8 JSON document as a string.
Exceptions
- NotSupportedException
A row holds a value with no JSON representation (
NaN/±∞) or an unsupported CLR type.
WriteJson(Utf8JsonWriter, DataContext)
Serializes the parameter as a JSON array: an array of scalar values for a scalar row type, or an
array of objects keyed by the mapped column name for an entity. Nulls become JSON null,
dates and times are ISO-8601 strings, byte[] is base64, enums are their underlying number,
and a duration on a provider without a native duration type is its stored integer.
public void WriteJson(Utf8JsonWriter writer, DataContext context)
Parameters
writerUtf8JsonWriterThe writer to write to.
contextDataContextThe context supplying the naming convention and dialect.
Exceptions
- NotSupportedException
A row holds a value with no JSON representation (
NaN/±∞) or an unsupported CLR type.