Class DuckDbParameterCollection
ADO.NET-compatible collection of parameters for DuckDbCommand.
Implements
Inherited Members
Namespace: Mallard.Ado
Assembly: Mallard.dll
Syntax
public sealed class DuckDbParameterCollection : IDataParameterCollection, IList, ICollection, IList<IDbDataParameter>, ICollection<IDbDataParameter>, IEnumerable<IDbDataParameter>, IEnumerable
Remarks
This implementation of IDataParameterCollection is essentially a plain list of the parameters. Most validation happens when the DuckDbCommand is executed, not when a parameter is added to this collection.
Parameter objects that may be set into this collection can be named or unnamed, respectively meaning that they have ParameterName being a non-empty string, or not. Unnamed parameters are assumed to refer to positional parameters in the DuckDB SQL statement. Positional parameters may also be named with a string that is the decimal representation (in ASCII digits, no leading zeros) of the positional index.
It is not recommended to mix named and unnamed parameter objects in the same collection. While that is not outright disallowed by this implementation (mainly because the validation is not trivial), there may be surprising behavior regarding how the parameter objects are actually mapped to the formal parameters in the SQL statement.
Properties
| Edit this page View SourceCount
The number of parameters in this collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
IsFixedSize
Gets a value indicating whether the IList has a fixed size.
Declaration
public bool IsFixedSize { get; }
Property Value
Type | Description |
---|---|
bool |
IsReadOnly
Gets a value indicating whether the IList is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
bool |
IsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
Declaration
public bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
bool | true if access to the ICollection is synchronized (thread safe); otherwise, false. |
this[int]
Set a parameter at a given index of this collection.
Declaration
public IDbDataParameter this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the slot to set the parameter object into, from 0 (inclusive) to Count (exclusive). This value is only for indexing into the parameter collection in .NET; it is not necessarily connected to the index of positional parameters in a DuckDB SQL statement. Which formal parameter in the SQL statement that the IDbDataParameter object is mapped to depends on ParameterName. |
Property Value
Type | Description |
---|---|
IDbDataParameter |
Remarks
That being said, unnamed parameter objects (those with an empty string for ParameterName) will be assigned to increasing indices for positional parameters in the SQL statement when it is executed.
this[string]
Set (the value of) a parameter keyed by its name.
Declaration
public IDbDataParameter this[string parameterName] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
string | parameterName | The name of the parameter to set. A parameter object with this name must have been added earlier to this collection. |
Property Value
Type | Description |
---|---|
IDbDataParameter |
Remarks
Every parameter is stored with an index within this container, that has no relation with its name (ParameterName). Calling the setter on this property will replace the parameter object, at the index where a current parameter with the given name lives. The new parameter object may have a different name, replacing the old parameter's name (if different). (This behavior is consistent with other implementations of IDataParameterCollection.)
If the new parameter object being set is unnamed,
meaning that ParameterName is an empty string,
its name will automatically be set to parameterName
.
SyncRoot
Gets an object that can be used to synchronize access to the ICollection.
Declaration
public object SyncRoot { get; }
Property Value
Type | Description |
---|---|
object | An object that can be used to synchronize access to the ICollection. |
Methods
| Edit this page View SourceAdd(IDbDataParameter)
Adds an item to the ICollection<T>.
Declaration
public void Add(IDbDataParameter value)
Parameters
Type | Name | Description |
---|---|---|
IDbDataParameter | value |
Exceptions
Type | Condition |
---|---|
NotSupportedException | The ICollection<T> is read-only. |
Clear()
Removes all items from the IList.
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
NotSupportedException | The IList is read-only. |
Contains(IDbDataParameter)
Determines whether the ICollection<T> contains a specific value.
Declaration
public bool Contains(IDbDataParameter value)
Parameters
Type | Name | Description |
---|---|---|
IDbDataParameter | value |
Returns
Type | Description |
---|---|
bool | true if |
Contains(string)
Gets a value indicating whether a parameter in the collection has the specified name.
Declaration
public bool Contains(string parameterName)
Parameters
Type | Name | Description |
---|---|---|
string | parameterName | The name of the parameter. |
Returns
Type | Description |
---|---|
bool | true if the collection contains the parameter; otherwise, false. |
CopyTo(Array, int)
Copies the elements of the ICollection to an Array, starting at a particular Array index.
Declaration
public void CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
Array | array | The one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing. |
int | index | The zero-based index in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
ArgumentException |
-or- The number of elements in the source ICollection is greater than the available space from -or- The type of the source ICollection cannot be cast automatically to the type of the destination |
CopyTo(IDbDataParameter[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
Declaration
public void CopyTo(IDbDataParameter[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
IDbDataParameter[] | array | The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing. |
int | arrayIndex | The zero-based index in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
ArgumentException | The number of elements in the source ICollection<T> is greater than the available space from |
IndexOf(IDbDataParameter)
Determines the index of a specific item in the IList<T>.
Declaration
public int IndexOf(IDbDataParameter value)
Parameters
Type | Name | Description |
---|---|---|
IDbDataParameter | value |
Returns
Type | Description |
---|---|
int | The index of |
IndexOf(string)
Gets the location of the IDataParameter within the collection.
Declaration
public int IndexOf(string parameterName)
Parameters
Type | Name | Description |
---|---|---|
string | parameterName | The name of the parameter. |
Returns
Type | Description |
---|---|
int | The zero-based location of the IDataParameter within the collection. |
Insert(int, IDbDataParameter)
Inserts an item to the IList<T> at the specified index.
Declaration
public void Insert(int index, IDbDataParameter item)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index at which |
IDbDataParameter | item | The object to insert into the IList<T>. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
NotSupportedException | The IList<T> is read-only. |
Remove(IDbDataParameter)
Removes the first occurrence of a specific object from the ICollection<T>.
Declaration
public bool Remove(IDbDataParameter item)
Parameters
Type | Name | Description |
---|---|---|
IDbDataParameter | item | The object to remove from the ICollection<T>. |
Returns
Type | Description |
---|---|
bool | true if |
Exceptions
Type | Condition |
---|---|
NotSupportedException | The ICollection<T> is read-only. |
RemoveAt(int)
Removes the IList item at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the item to remove. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
NotSupportedException | The IList is read-only. -or- The IList has a fixed size. |
RemoveAt(string)
Removes the IDataParameter from the collection.
Declaration
public void RemoveAt(string parameterName)
Parameters
Type | Name | Description |
---|---|---|
string | parameterName | The name of the parameter. |