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
parameterName
stringThe name of the parameter to map.
parameterType
NpgsqlDbTypeOne of the NpgsqlDbType values.
NpgsqlParameter(string?, NpgsqlDbType, int)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string? parameterName, NpgsqlDbType parameterType, int size)
Parameters
parameterName
stringThe name of the parameter to map.
parameterType
NpgsqlDbTypeOne of the NpgsqlDbType values.
size
intThe 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
parameterName
stringThe name of the parameter to map.
parameterType
NpgsqlDbTypeOne of the NpgsqlDbType values.
size
intThe length of the parameter.
sourceColumn
stringThe 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
parameterName
stringThe name of the parameter to map.
parameterType
NpgsqlDbTypeOne of the NpgsqlDbType values.
size
intThe length of the parameter.
sourceColumn
stringThe name of the source column.
direction
ParameterDirectionOne of the ParameterDirection values.
isNullable
booltrue if the value of the field can be null, otherwise false.
precision
byteThe total number of digits to the left and right of the decimal point to which Value is resolved.
scale
byteThe total number of decimal places to which Value is resolved.
sourceVersion
DataRowVersionOne of the DataRowVersion values.
value
objectAn 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
parameterName
stringThe name of the parameter to map.
parameterType
DbTypeOne of the DbType values.
NpgsqlParameter(string?, DbType, int)
Initializes a new instance of the NpgsqlParameter.
public NpgsqlParameter(string? parameterName, DbType parameterType, int size)
Parameters
parameterName
stringThe name of the parameter to map.
parameterType
DbTypeOne of the DbType values.
size
intThe 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
parameterName
stringThe name of the parameter to map.
parameterType
DbTypeOne of the DbType values.
size
intThe length of the parameter.
sourceColumn
stringThe 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
parameterName
stringThe name of the parameter to map.
parameterType
DbTypeOne of the DbType values.
size
intThe length of the parameter.
sourceColumn
stringThe name of the source column.
direction
ParameterDirectionOne of the ParameterDirection values.
isNullable
booltrue if the value of the field can be null, otherwise false.
precision
byteThe total number of digits to the left and right of the decimal point to which Value is resolved.
scale
byteThe total number of decimal places to which Value is resolved.
sourceVersion
DataRowVersionOne of the DataRowVersion values.
value
objectAn 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.
public NpgsqlParameter(string? parameterName, object? value)
Parameters
parameterName
stringThe name of the parameter to map.
value
objectThe value of the NpgsqlParameter.
Remarks
When you specify an object in the value parameter, the DbType is inferred from the CLR type.
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 ToInt32(object) 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
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
Gets or sets a value that indicates whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.
public override sealed ParameterDirection Direction { get; set; }
Property Value
- ParameterDirection
One of the ParameterDirection values. The default is
Input
.
Exceptions
- ArgumentException
The property is not set to one of the valid ParameterDirection values.
IsNullable
Gets or sets a value that indicates whether the parameter accepts null values.
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 NpgsqlDbType.
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
Gets or sets the maximum size, in bytes, of the data within the column.
public override sealed int Size { get; set; }
Property Value
- int
The maximum size, in bytes, of the data within the column. The default value is inferred from the parameter value.
SourceColumn
Gets or sets the name of the source column mapped to the DataSet and used for loading or returning the Value.
public override sealed string SourceColumn { get; set; }
Property Value
SourceColumnNullMapping
Gets or sets a value which indicates whether the source column is nullable. This allows DbCommandBuilder to correctly generate Update statements for nullable columns.
public override sealed bool SourceColumnNullMapping { get; set; }
Property Value
SourceVersion
Gets or sets the DataRowVersion to use when you load Value.
public override sealed DataRowVersion SourceVersion { get; set; }
Property Value
- DataRowVersion
One of the DataRowVersion values. The default is
Current
.
Exceptions
- ArgumentException
The property is not set to one of the DataRowVersion values.
Value
Gets or sets the value of the parameter.
[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()
Resets the DbType property to its original settings.
public override void ResetDbType()