Struct DuckDbStatement.ParametersCollection
The collection of formal parameters in a prepared statement from DuckDB.
Implements
Inherited Members
Namespace: Mallard
Assembly: Mallard.dll
Syntax
public readonly struct DuckDbStatement.ParametersCollection : IReadOnlyCollection<DuckDbStatement.Parameter>, IEnumerable<DuckDbStatement.Parameter>, IEnumerable
Remarks
This collection is essentially an ordered list of the parameters. (It does not implement IReadOnlyList<T> only because DuckDB's parameters are defined to be numbered starting from 1, not 0.)
Parameters may also be looked up by the name they have been defined under in the SQL prepared statement.
Properties
| Edit this page View SourceCount
Get the number of parameters available to bind in the DuckDB statement.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int | The total number of parameters. |
this[int]
Get one of the parameters, by positional index.
Declaration
public DuckDbStatement.Parameter this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | 1-based index of the parameter.
Currently, DuckDB does not support mixing named and positional parameters,
so if positional parameters are being used, this index
should match up exactly with the ordinal of the parameter in the SQL statement,
e.g. |
Property Value
Type | Description |
---|---|
DuckDbStatement.Parameter |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
this[string]
Get one of the parameters, by name.
Declaration
public DuckDbStatement.Parameter this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the parameter. For positional parameters in the SQL statement, the name is the decimal representation of the ordinal (in ASCII digits, no leading zeros). |
Property Value
Type | Description |
---|---|
DuckDbStatement.Parameter |
Exceptions
Type | Condition |
---|---|
ArgumentException | There is no parameter with the given name from the prepared statement. |
ObjectDisposedException | The prepared statement for this parameter collection has already been disposed. (Looking up the name requires querying the native prepared statement object from DuckDB.) |
Methods
| Edit this page View SourceGetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<DuckDbStatement.Parameter> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<DuckDbStatement.Parameter> | An enumerator that can be used to iterate through the collection. |
GetIndexForName(string)
Get the index of the parameter with the given name.
Declaration
public int GetIndexForName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the parameter in the SQL statement. |
Returns
Type | Description |
---|---|
int | The 1-based index of the named parameter, suitable for indexing into this collection. If no parameter with the given name exists, -1 is returned. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The prepared statement for this parameter collection has already been disposed. (Looking up the name requires querying the native prepared statement object from DuckDB.) |