Struct ProcedureParameter
Describes a single parameter of a raw command or stored procedure: its name, value and the ADO.NET
parameter options (ParameterDirection, DbType, Size,
TypeName). The same shape serves raw parameterised SQL (ExecuteRaw) and stored
procedures (ExecuteProcedure).
public readonly record struct ProcedureParameter : IEquatable<ProcedureParameter>
- Implements
- Inherited Members
- Extension Methods
Constructors
ProcedureParameter(string, object?, ParameterDirection, DbType?, int?, string?)
Describes a single parameter of a raw command or stored procedure: its name, value and the ADO.NET
parameter options (ParameterDirection, DbType, Size,
TypeName). The same shape serves raw parameterised SQL (ExecuteRaw) and stored
procedures (ExecuteProcedure).
public ProcedureParameter(string Name, object? Value, ParameterDirection Direction = ParameterDirection.Input, DbType? DbType = null, int? Size = null, string? TypeName = null)
Parameters
NamestringThe parameter name, without the provider's prefix (for example the SQL Server
@).ValueobjectThe value bound to the parameter, or null for a SQL
NULL.DirectionParameterDirectionThe parameter direction. Defaults to Input.
DbTypeDbType?An explicit provider-independent type, or null to let the provider infer it from
Value.Sizeint?The parameter size in bytes/characters, or null for the provider default.
TypeNamestringThe provider type name of a structured (table-valued) parameter, or null for an ordinary parameter.
Properties
DbType
An explicit provider-independent type, or null to let the provider infer it from Value.
public DbType? DbType { get; init; }
Property Value
Direction
The parameter direction. Defaults to Input.
public ParameterDirection Direction { get; init; }
Property Value
Name
The parameter name, without the provider's prefix (for example the SQL Server @).
public string Name { get; init; }
Property Value
Size
The parameter size in bytes/characters, or null for the provider default.
public int? Size { get; init; }
Property Value
- int?
TypeName
The provider type name of a structured (table-valued) parameter, or null for an ordinary parameter.
public string? TypeName { get; init; }
Property Value
Value
The value bound to the parameter, or null for a SQL NULL.
public object? Value { get; init; }
Property Value
Methods
Table<T>(string, IEnumerable<T>)
Creates an input table-valued parameter from a sequence of rows, for a provider that emulates a
table parameter (PostgreSQL and ClickHouse typed arrays; MySQL/MariaDB and SQLite JSON). SQL
Server has no emulation — it binds a native user-defined table type — so it requires the
typeName argument and must use the overload that takes it. The provider decides how the
rows are bound; see each provider's documentation.
public static ProcedureParameter Table<T>(string name, IEnumerable<T> rows)
Parameters
namestringThe parameter name, without the provider's prefix.
rowsIEnumerable<T>The rows to bind. An empty sequence binds an empty set.
Returns
- ProcedureParameter
An input table-valued parameter descriptor.
Type Parameters
TThe CLR type of each row.
Exceptions
- ArgumentException
nameis null, empty or whitespace.- ArgumentNullException
rowsis null.
Table<T>(string, string, IEnumerable<T>)
Creates an input table-valued parameter for a provider with a named table type (SQL Server user-defined table type); the other providers reject a type name because they emulate the table parameter with a typed array or a JSON document and have no named type to bind.
public static ProcedureParameter Table<T>(string name, string typeName, IEnumerable<T> rows)
Parameters
namestringThe parameter name, without the provider's prefix.
typeNamestringThe user-defined table type name (SQL Server only).
rowsIEnumerable<T>The rows to bind. An empty sequence binds an empty set.
Returns
- ProcedureParameter
An input table-valued parameter descriptor.
Type Parameters
TThe CLR type of each row.
Exceptions
- ArgumentException
nameortypeNameis null, empty or whitespace.- ArgumentNullException
rowsis null.