# Class NpgsqlParameterCollection

Namespace
  Npgsql

Assembly
  Npgsql.dll

Represents a collection of parameters relevant to a NpgsqlCommand as well as their respective mappings to columns in a DataSet.

    public sealed class NpgsqlParameterCollection : DbParameterCollection, IDataParameterCollection, IList, ICollection, IList<NpgsqlParameter>, ICollection<NpgsqlParameter>, IEnumerable<NpgsqlParameter>, IEnumerable

Inheritance
  object
  MarshalByRefObject
  DbParameterCollection
  NpgsqlParameterCollection

Implements
  IDataParameterCollection
  IList
  ICollection
  IList<NpgsqlParameter>
  ICollection<NpgsqlParameter>
  IEnumerable<NpgsqlParameter>
  IEnumerable

Inherited Members
  MarshalByRefObject.GetLifetimeService()
  MarshalByRefObject.InitializeLifetimeService()
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.ReferenceEquals(object, object)
  object.ToString()

## Properties

### Count

Gets the number of NpgsqlParameter objects in the collection.

    public override int Count { get; }

#### Property Value

int

  The number of NpgsqlParameter objects in the collection.

### IsFixedSize

Specifies whether the collection is a fixed size.

    public override bool IsFixedSize { get; }

#### Property Value

bool

  true if the collection is a fixed size; otherwise false.

### IsReadOnly

Specifies whether the collection is read-only.

    public override bool IsReadOnly { get; }

#### Property Value

bool

  true if the collection is read-only; otherwise false.

### IsSynchronized

Specifies whether the collection is synchronized.

    public override bool IsSynchronized { get; }

#### Property Value

bool

  true if the collection is synchronized; otherwise false.

### this[int]

Gets the NpgsqlParameter at the specified index.

    public NpgsqlParameter this[int index] { get; set; }

#### Parameters

`index` int

  The zero-based index of the NpgsqlParameter to retrieve.

#### Property Value

NpgsqlParameter

  The NpgsqlParameter at the specified index.

### this[string]

Gets the NpgsqlParameter with the specified name.

    public NpgsqlParameter this[string parameterName] { get; set; }

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter to retrieve.

#### Property Value

NpgsqlParameter

  The NpgsqlParameter with the specified name, or a null reference if the parameter is not found.

### SyncRoot

Specifies the object to be used to synchronize access to the collection.

    public override object SyncRoot { get; }

#### Property Value

object

  A object to be used to synchronize access to the DbParameterCollection.

## Methods

### Add(NpgsqlParameter)

Adds the specified NpgsqlParameter object to the NpgsqlParameterCollection.

    public NpgsqlParameter Add(NpgsqlParameter value)

#### Parameters

`value` NpgsqlParameter

  The NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### Add(object)

Adds the specified DbParameter object to the DbParameterCollection.

    public override int Add(object value)

#### Parameters

`value` object

  The Value of the DbParameter to add to the collection.

#### Returns

int

  The index of the DbParameter object in the collection.

### Add(string, NpgsqlDbType)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the parameter name and the data type.

    public NpgsqlParameter Add(string parameterName, NpgsqlDbType parameterType)

#### Parameters

`parameterName` string

  The name of the parameter.

`parameterType` NpgsqlDbType

  One of the DbType values.

#### Returns

NpgsqlParameter

  The parameter that was added.

### Add(string, NpgsqlDbType, int)

Adds a NpgsqlParameter to the NpgsqlParameterCollection with the parameter name, the data type, and the column length.

    public NpgsqlParameter Add(string parameterName, NpgsqlDbType parameterType, int size)

#### Parameters

`parameterName` string

  The name of the parameter.

`parameterType` NpgsqlDbType

  One of the DbType values.

`size` int

  The length of the column.

#### Returns

NpgsqlParameter

  The parameter that was added.

### Add(string, NpgsqlDbType, int, string)

Adds a NpgsqlParameter to the NpgsqlParameterCollection with the parameter name, the data type, the column length, and the source column name.

    public NpgsqlParameter Add(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn)

#### Parameters

`parameterName` string

  The name of the parameter.

`parameterType` NpgsqlDbType

  One of the DbType values.

`size` int

  The length of the column.

`sourceColumn` string

  The name of the source column.

#### Returns

NpgsqlParameter

  The parameter that was added.

### AddRange(Array)

Adds an array of items with the specified values to the DbParameterCollection.

    public override void AddRange(Array values)

#### Parameters

`values` Array

  An array of values of type DbParameter to add to the collection.

### AddWithValue(NpgsqlDbType, object)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified data type and value.

    public NpgsqlParameter AddWithValue(NpgsqlDbType parameterType, object value)

#### Parameters

`parameterType` NpgsqlDbType

  One of the NpgsqlDbType values.

`value` object

  The value of the NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### AddWithValue(object)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified value.

    public NpgsqlParameter AddWithValue(object value)

#### Parameters

`value` object

  The value of the NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### AddWithValue(string, NpgsqlDbType, int, object)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified parameter name and value.

    public NpgsqlParameter AddWithValue(string parameterName, NpgsqlDbType parameterType, int size, object value)

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter.

`parameterType` NpgsqlDbType

  One of the NpgsqlDbType values.

`size` int

  The length of the column.

`value` object

  The value of the NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### AddWithValue(string, NpgsqlDbType, int, string?, object)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified parameter name and value.

    public NpgsqlParameter AddWithValue(string parameterName, NpgsqlDbType parameterType, int size, string? sourceColumn, object value)

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter.

`parameterType` NpgsqlDbType

  One of the NpgsqlDbType values.

`size` int

  The length of the column.

`sourceColumn` string

  The name of the source column.

`value` object

  The value of the NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### AddWithValue(string, NpgsqlDbType, object)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified parameter name, data type and value.

    public NpgsqlParameter AddWithValue(string parameterName, NpgsqlDbType parameterType, object value)

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter.

`parameterType` NpgsqlDbType

  One of the NpgsqlDbType values.

`value` object

  The value of the NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### AddWithValue(string, object)

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified parameter name and value.

    public NpgsqlParameter AddWithValue(string parameterName, object value)

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter.

`value` object

  The value of the NpgsqlParameter to add to the collection.

#### Returns

NpgsqlParameter

  The parameter that was added.

### Clear()

Removes all items from the collection.

    public override void Clear()

### Contains(NpgsqlParameter)

Report whether the specified parameter is present in the collection.

    public bool Contains(NpgsqlParameter item)

#### Parameters

`item` NpgsqlParameter

  Parameter to find.

#### Returns

bool

  True if the parameter was found, otherwise false.

### Contains(object)

Indicates whether a DbParameter with the specified Value is contained in the collection.

    public override bool Contains(object value)

#### Parameters

`value` object

  The Value of the DbParameter to look for in the collection.

#### Returns

bool

  true if the DbParameter is in the collection; otherwise false.

### Contains(string)

Indicates whether a DbParameter with the specified name exists in the collection.

    public override bool Contains(string parameterName)

#### Parameters

`parameterName` string

#### Returns

bool

  true if the DbParameter is in the collection; otherwise false.

### CopyTo(NpgsqlParameter[], int)

Convert collection to a System.Array.

    public void CopyTo(NpgsqlParameter[] array, int arrayIndex)

#### Parameters

`array` NpgsqlParameter[]

  Destination array.

`arrayIndex` int

  Starting index in destination array.

### CopyTo(Array, int)

Copies an array of items to the collection starting at the specified index.

    public override void CopyTo(Array array, int index)

#### Parameters

`array` Array

  The array of items to copy to the collection.

`index` int

  The index in the collection to copy the items.

### GetEnumerator()

Exposes the GetEnumerator() method, which supports a simple iteration over a collection by a .NET data provider.

    public override IEnumerator GetEnumerator()

#### Returns

IEnumerator

  An IEnumerator that can be used to iterate through the collection.

### GetParameter(int)

Returns the DbParameter object at the specified index in the collection.

    protected override DbParameter GetParameter(int index)

#### Parameters

`index` int

  The index of the DbParameter in the collection.

#### Returns

DbParameter

  The DbParameter object at the specified index in the collection.

### GetParameter(string)

Returns DbParameter the object with the specified name.

    protected override DbParameter GetParameter(string parameterName)

#### Parameters

`parameterName` string

  The name of the DbParameter in the collection.

#### Returns

DbParameter

  The DbParameter the object with the specified name.

### IndexOf(NpgsqlParameter)

Report the offset within the collection of the given parameter.

    public int IndexOf(NpgsqlParameter item)

#### Parameters

`item` NpgsqlParameter

  Parameter to find.

#### Returns

int

  Index of the parameter, or -1 if the parameter is not present.

### IndexOf(object)

Returns the index of the specified DbParameter object.

    public override int IndexOf(object value)

#### Parameters

`value` object

  The DbParameter object in the collection.

#### Returns

int

  The index of the specified DbParameter object.

### IndexOf(string)

Returns the index of the DbParameter object with the specified name.

    public override int IndexOf(string parameterName)

#### Parameters

`parameterName` string

  The name of the DbParameter object in the collection.

#### Returns

int

  The index of the DbParameter object with the specified name.

### Insert(int, NpgsqlParameter)

Insert the specified parameter into the collection.

    public void Insert(int index, NpgsqlParameter item)

#### Parameters

`index` int

  Index of the existing parameter before which to insert the new one.

`item` NpgsqlParameter

  Parameter to insert.

### Insert(int, object)

Inserts the specified index of the DbParameter object with the specified name into the collection at the specified index.

    public override void Insert(int index, object value)

#### Parameters

`index` int

  The index at which to insert the DbParameter object.

`value` object

  The DbParameter object to insert into the collection.

### Remove(NpgsqlParameter)

Remove the specified parameter from the collection.

    public bool Remove(NpgsqlParameter item)

#### Parameters

`item` NpgsqlParameter

  Parameter to remove.

#### Returns

bool

  True if the parameter was found and removed, otherwise false.

### Remove(object)

Removes the specified NpgsqlParameter from the collection.

    public override void Remove(object value)

#### Parameters

`value` object

  The NpgsqlParameter to remove from the collection.

### Remove(string)

Removes the specified NpgsqlParameter from the collection.

    public void Remove(string parameterName)

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter to remove from the collection.

### RemoveAt(int)

Removes the specified NpgsqlParameter from the collection using a specific index.

    public override void RemoveAt(int index)

#### Parameters

`index` int

  The zero-based index of the parameter.

### RemoveAt(string)

Removes the DbParameter object with the specified name from the collection.

    public override void RemoveAt(string parameterName)

#### Parameters

`parameterName` string

  The name of the DbParameter object to remove.

### SetParameter(int, DbParameter)

Sets the DbParameter object at the specified index to a new value.

    protected override void SetParameter(int index, DbParameter value)

#### Parameters

`index` int

  The index where the DbParameter object is located.

`value` DbParameter

  The new DbParameter value.

### SetParameter(string, DbParameter)

Sets the DbParameter object with the specified name to a new value.

    protected override void SetParameter(string parameterName, DbParameter value)

#### Parameters

`parameterName` string

  The name of the DbParameter object in the collection.

`value` DbParameter

  The new DbParameter value.

### ToArray()

Convert collection to a System.Array.

    public NpgsqlParameter[] ToArray()

#### Returns

NpgsqlParameter[]

  NpgsqlParameter[]

### TryGetValue(string, out NpgsqlParameter?)

Gets a value indicating whether a NpgsqlParameter with the specified parameter name exists in the collection.

    public bool TryGetValue(string parameterName, out NpgsqlParameter? parameter)

#### Parameters

`parameterName` string

  The name of the NpgsqlParameter object to find.

`parameter` NpgsqlParameter

  A reference to the requested parameter is returned in this out param if it is found in the list. This value is null if the parameter is not found.

#### Returns

bool

  true if the collection contains the parameter and param will contain the parameter; otherwise, false.