Class SqlNamedParameterCollection
- Namespace
- LfrlAnvil.Sql.Statements
- Assembly
- LfrlAnvil.Sql.Core.dll
Represents a collection of type-erased bindable named SQL parameters.
public sealed class SqlNamedParameterCollection : IReadOnlyCollection<SqlParameter>, IEnumerable<SqlParameter>, IEnumerable
- Inheritance
-
SqlNamedParameterCollection
- Implements
- Inherited Members
Constructors
SqlNamedParameterCollection(int, IEqualityComparer<string>?)
Creates a new empty SqlNamedParameterCollection instance.
public SqlNamedParameterCollection(int capacity = 0, IEqualityComparer<string>? comparer = null)
Parameters
capacity
intInitial capacity.
comparer
IEqualityComparer<string>Optional parameter name equality comparer.
Exceptions
- ArgumentOutOfRangeException
When
capacity
is less than 0.
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
Methods
AddOrUpdate(string, object?)
Adds a new parameter to this collection or updates the value of an existing parameter.
public void AddOrUpdate(string name, object? value)
Parameters
Clear()
Removes all parameters from this collection.
public void Clear()
Contains(string)
Checks whether or not a parameter with the specified name
exists.
[Pure]
public bool Contains(string name)
Parameters
name
stringName to check.
Returns
- bool
true when parameter exists, otherwise false.
GetEnumerator()
Returns an enumerator that iterates through the collection.
[Pure]
public IEnumerator<SqlParameter> GetEnumerator()
Returns
- IEnumerator<SqlParameter>
An enumerator that can be used to iterate through the collection.
TryAdd(string, object?)
Attempts to add a new parameter to this collection.
public bool TryAdd(string name, object? value)
Parameters
Returns
- bool
true when parameter was added, otherwise false.
TryGet(string)
Attempts to return an SqlParameter instance associated with the provided name
.
[Pure]
public SqlParameter? TryGet(string name)
Parameters
name
stringName of the parameter to get.
Returns
- SqlParameter?
SqlParameter instance or null when parameter does not exist.