Npgsql.NpgsqlParameterCollection.AddWithValue C# (CSharp) Method

AddWithValue() public method

Adds a NpgsqlParameter to the NpgsqlParameterCollection given the specified parameter name and value.
public AddWithValue ( string parameterName, object value ) : Npgsql.NpgsqlParameter
parameterName string The name of the NpgsqlParameter.
value object The Value of the NpgsqlParameter to add to the collection.
return Npgsql.NpgsqlParameter
        public NpgsqlParameter AddWithValue(string parameterName, object value)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "AddWithValue", parameterName, value);
            return this.Add(new NpgsqlParameter(parameterName, value));
        }

Same methods

NpgsqlParameterCollection::AddWithValue ( string parameterName, NpgsqlDbType parameterType, int size, object value ) : Npgsql.NpgsqlParameter
NpgsqlParameterCollection::AddWithValue ( string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn, object value ) : Npgsql.NpgsqlParameter
NpgsqlParameterCollection::AddWithValue ( string parameterName, NpgsqlDbType parameterType, object value ) : Npgsql.NpgsqlParameter

Usage Example

        /// <summary>
        /// Add range with value
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="values"></param>
        public static void AddRangeWithValue(this NpgsqlParameterCollection conn, Dictionary <string, object> values)
        {
            conn.CheckNull(nameof(conn));
#if NETFRAMEWORK || NETSTANDARD2_0
            foreach (var pair in values)
            {
                var key   = pair.Key;
                var value = pair.Value;
#else
            foreach (var(key, value) in values)
            {
#endif
                conn.AddWithValue(key, value);
            }
        }
    }