Class NpgsqlParameter
- Namespace
- Npgsql
- Assembly
- Npgsql.dll
This class represents a parameter to a command that will be sent to server
public class NpgsqlParameter : DbParameter, IDbDataParameter, IDataParameter, ICloneable
- Inheritance
-
NpgsqlParameter
- Implements
- Derived
- Inherited Members
Constructors
NpgsqlParameter()
Initializes a new instance of the NpgsqlParameter class.
public NpgsqlParameter()
NpgsqlParameter(string, NpgsqlDbType)
Initializes a new instance of the NpgsqlParameter class with the parameter name and the data type.
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeNpgsqlDbTypeOne of the DbType values.
NpgsqlParameter(string, NpgsqlDbType, int)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeNpgsqlDbTypeOne of the NpgsqlDbType values.
sizeintThe length of the parameter.
NpgsqlParameter(string, NpgsqlDbType, int, string)
Initializes a new instance of the NpgsqlParameter
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeNpgsqlDbTypeOne of the NpgsqlDbType values.
sizeintThe length of the parameter.
sourceColumnstringThe name of the source column.
NpgsqlParameter(string, NpgsqlDbType, int, string, ParameterDirection, bool, byte, byte, DataRowVersion, object)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn, ParameterDirection direction, bool isNullable, byte precision, byte scale, DataRowVersion sourceVersion, object value)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeNpgsqlDbTypeOne of the NpgsqlDbType values.
sizeintThe length of the parameter.
sourceColumnstringThe name of the source column.
directionParameterDirectionOne of the ParameterDirection values.
isNullablebooltrue if the value of the field can be null, otherwise false.
precisionbyteThe total number of digits to the left and right of the decimal point to which Value is resolved.
scalebyteThe total number of decimal places to which Value is resolved.
sourceVersionDataRowVersionOne of the DataRowVersion values.
valueobjectAn Object that is the value of the NpgsqlParameter.
NpgsqlParameter(string, DbType)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string parameterName, DbType parameterType)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeDbTypeOne of the DbType values.
NpgsqlParameter(string, DbType, int)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string parameterName, DbType parameterType, int size)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeDbTypeOne of the DbType values.
sizeintThe length of the parameter.
NpgsqlParameter(string, DbType, int, string)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string parameterName, DbType parameterType, int size, string sourceColumn)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeDbTypeOne of the DbType values.
sizeintThe length of the parameter.
sourceColumnstringThe name of the source column.
NpgsqlParameter(string, DbType, int, string, ParameterDirection, bool, byte, byte, DataRowVersion, object)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string parameterName, DbType parameterType, int size, string sourceColumn, ParameterDirection direction, bool isNullable, byte precision, byte scale, DataRowVersion sourceVersion, object value)
Parameters
parameterNamestringThe name of the parameter to map.
parameterTypeDbTypeOne of the DbType values.
sizeintThe length of the parameter.
sourceColumnstringThe name of the source column.
directionParameterDirectionOne of the ParameterDirection values.
isNullablebooltrue if the value of the field can be null, otherwise false.
precisionbyteThe total number of digits to the left and right of the decimal point to which Value is resolved.
scalebyteThe total number of decimal places to which Value is resolved.
sourceVersionDataRowVersionOne of the DataRowVersion values.
valueobjectAn Object that is the value of the NpgsqlParameter.
NpgsqlParameter(string, object)
Initializes a new instance of the NpgsqlParameter class with the parameter name and a value of the new NpgsqlParameter.
public NpgsqlParameter(string parameterName, object value)
Parameters
parameterNamestringThe name of the parameter to map.
valueobjectAn Object that is the value of the NpgsqlParameter.
Remarks
When you specify an Object in the value parameter, the DbType is inferred from the .NET Framework type of the Object.
When using this constructor, you must be aware of a possible misuse of the constructor which takes a DbType parameter. This happens when calling this constructor passing an int 0 and the compiler thinks you are passing a value of DbType. Use
Convert.ToInt32(value) for example to have compiler calling the correct constructor.
Properties
Collection
The collection to which this parameter belongs, if any.
public NpgsqlParameterCollection Collection { get; set; }
Property Value
ConvertedValue
Can be used to communicate a value from the validation phase to the writing phase. To be used by type handlers only.
public object ConvertedValue { get; set; }
Property Value
DataTypeName
Used to specify which PostgreSQL type will be sent to the database for this parameter.
public string DataTypeName { get; set; }
Property Value
DbType
Gets or sets the DbType of the parameter.
public override sealed DbType DbType { get; set; }
Property Value
Direction
public override sealed ParameterDirection Direction { get; set; }
Property Value
IsNullable
public override sealed bool IsNullable { get; set; }
Property Value
NpgsqlDbType
Gets or sets the NpgsqlDbType of the parameter.
[DbProviderSpecificTypeProperty(true)]
public NpgsqlDbType NpgsqlDbType { get; set; }
Property Value
- NpgsqlDbType
One of the NpgsqlDbType values. The default is Unknown.
NpgsqlValue
Gets or sets the value of the parameter.
[TypeConverter(typeof(StringConverter))]
public object NpgsqlValue { get; set; }
Property Value
ParameterName
Gets or sets The name of the NpgsqlParameter.
public override sealed string ParameterName { get; set; }
Property Value
- string
The name of the NpgsqlParameter. The default is an empty string.
PostgresType
The PostgreSQL data type, such as int4 or text, as discovered from pg_type. This property is automatically set if parameters have been derived via DeriveParameters(NpgsqlCommand) and can be used to acquire additional information about the parameters' data type.
public PostgresType PostgresType { get; }
Property Value
Precision
Gets or sets the maximum number of digits used to represent the Value property.
public byte Precision { get; set; }
Property Value
- byte
The maximum number of digits used to represent the Value property. The default value is 0, which indicates that the data provider sets the precision for Value.
Scale
Gets or sets the number of decimal places to which Value is resolved.
public byte Scale { get; set; }
Property Value
Size
public override sealed int Size { get; set; }
Property Value
SourceColumn
public override sealed string SourceColumn { get; set; }
Property Value
SourceColumnNullMapping
public override sealed bool SourceColumnNullMapping { get; set; }
Property Value
SourceVersion
public override sealed DataRowVersion SourceVersion { get; set; }
Property Value
Value
[TypeConverter(typeof(StringConverter))]
public override object Value { get; set; }
Property Value
Methods
Clone()
Creates a new NpgsqlParameter that is a copy of the current instance.
public NpgsqlParameter Clone()
Returns
- NpgsqlParameter
A new NpgsqlParameter that is a copy of this instance.
ResetDbType()
public override void ResetDbType()