Class NpgsqlParameter
This class represents a parameter to a command that will be sent to server
Inherited Members
Namespace: Npgsql
Assembly: Npgsql.dll
Syntax
public class NpgsqlParameter : DbParameter, IDbDataParameter, IDataParameter, ICloneable
Constructors
| Improve this DocNpgsqlParameter()
Initializes a new instance of the NpgsqlParameter class.
Declaration
public NpgsqlParameter()
NpgsqlParameter(String, NpgsqlDbType)
Initializes a new instance of the NpgsqlParameter class with the parameter name and the data type.
Declaration
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
NpgsqlParameter(String, NpgsqlDbType, Int32)
Initializes a new instance of the NpgsqlParameter.
Declaration
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
Int32 | size | The length of the parameter. |
NpgsqlParameter(String, NpgsqlDbType, Int32, String)
Initializes a new instance of the NpgsqlParameter
Declaration
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
Int32 | size | The length of the parameter. |
String | sourceColumn | The name of the source column. |
NpgsqlParameter(String, NpgsqlDbType, Int32, String, ParameterDirection, Boolean, Byte, Byte, DataRowVersion, Object)
Initializes a new instance of the NpgsqlParameter.
Declaration
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn, ParameterDirection direction, bool isNullable, byte precision, byte scale, DataRowVersion sourceVersion, object value)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
Int32 | size | The length of the parameter. |
String | sourceColumn | The name of the source column. |
ParameterDirection | direction | One of the ParameterDirection values. |
Boolean | isNullable | true if the value of the field can be null, otherwise false. |
Byte | precision | The total number of digits to the left and right of the decimal point to which Value is resolved. |
Byte | scale | The total number of decimal places to which Value is resolved. |
DataRowVersion | sourceVersion | One of the DataRowVersion values. |
Object | value | An Object that is the value of the NpgsqlParameter. |
NpgsqlParameter(String, DbType)
Initializes a new instance of the NpgsqlParameter.
Declaration
public NpgsqlParameter(string parameterName, DbType parameterType)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
DbType | parameterType | One of the DbType values. |
NpgsqlParameter(String, DbType, Int32)
Initializes a new instance of the NpgsqlParameter.
Declaration
public NpgsqlParameter(string parameterName, DbType parameterType, int size)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
DbType | parameterType | One of the DbType values. |
Int32 | size | The length of the parameter. |
NpgsqlParameter(String, DbType, Int32, String)
Initializes a new instance of the NpgsqlParameter.
Declaration
public NpgsqlParameter(string parameterName, DbType parameterType, int size, string sourceColumn)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
DbType | parameterType | One of the DbType values. |
Int32 | size | The length of the parameter. |
String | sourceColumn | The name of the source column. |
NpgsqlParameter(String, DbType, Int32, String, ParameterDirection, Boolean, Byte, Byte, DataRowVersion, Object)
Initializes a new instance of the NpgsqlParameter.
Declaration
public NpgsqlParameter(string parameterName, DbType parameterType, int size, string sourceColumn, ParameterDirection direction, bool isNullable, byte precision, byte scale, DataRowVersion sourceVersion, object value)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
DbType | parameterType | One of the DbType values. |
Int32 | size | The length of the parameter. |
String | sourceColumn | The name of the source column. |
ParameterDirection | direction | One of the ParameterDirection values. |
Boolean | isNullable | true if the value of the field can be null, otherwise false. |
Byte | precision | The total number of digits to the left and right of the decimal point to which Value is resolved. |
Byte | scale | The total number of decimal places to which Value is resolved. |
DataRowVersion | sourceVersion | One of the DataRowVersion values. |
Object | value | An 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.
Declaration
public NpgsqlParameter(string parameterName, object value)
Parameters
Type | Name | Description |
---|---|---|
String | parameterName | The name of the parameter to map. |
Object | value | An 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
| Improve this DocCollection
The collection to which this parameter belongs, if any.
Declaration
public NpgsqlParameterCollection Collection { get; set; }
Property Value
Type | Description |
---|---|
NpgsqlParameterCollection |
ConvertedValue
Can be used to communicate a value from the validation phase to the writing phase. To be used by type handlers only.
Declaration
public object ConvertedValue { get; set; }
Property Value
Type | Description |
---|---|
Object |
DataTypeName
Used to specify which PostgreSQL type will be sent to the database for this parameter.
Declaration
public string DataTypeName { get; set; }
Property Value
Type | Description |
---|---|
String |
DbType
Gets or sets the DbType of the parameter.
Declaration
public sealed override DbType DbType { get; set; }
Property Value
Type | Description |
---|---|
DbType | One of the DbType values. The default is Object. |
Overrides
| Improve this DocDirection
Declaration
public sealed override ParameterDirection Direction { get; set; }
Property Value
Type | Description |
---|---|
ParameterDirection |
Overrides
| Improve this DocIsNullable
Declaration
public sealed override bool IsNullable { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
| Improve this DocNpgsqlDbType
Gets or sets the NpgsqlDbType of the parameter.
Declaration
[DbProviderSpecificTypeProperty(true)]
public NpgsqlDbType NpgsqlDbType { get; set; }
Property Value
Type | Description |
---|---|
NpgsqlDbType | One of the NpgsqlDbType values. The default is Unknown. |
NpgsqlValue
Gets or sets the value of the parameter.
Declaration
[TypeConverter(typeof(StringConverter))]
public object NpgsqlValue { get; set; }
Property Value
Type | Description |
---|---|
Object | An Object that is the value of the parameter. The default value is null. |
ParameterName
Gets or sets The name of the NpgsqlParameter.
Declaration
public sealed override string ParameterName { get; set; }
Property Value
Type | Description |
---|---|
String | The name of the NpgsqlParameter. The default is an empty string. |
Overrides
| Improve this DocPostgresType
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.
Declaration
public PostgresType PostgresType { get; }
Property Value
Type | Description |
---|---|
PostgresType |
Precision
Gets or sets the maximum number of digits used to represent the Value property.
Declaration
public byte Precision { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public byte Scale { get; set; }
Property Value
Type | Description |
---|---|
Byte | The number of decimal places to which Value is resolved. The default is 0. |
Size
Declaration
public sealed override int Size { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Overrides
| Improve this DocSourceColumn
Declaration
public sealed override string SourceColumn { get; set; }
Property Value
Type | Description |
---|---|
String |
Overrides
| Improve this DocSourceColumnNullMapping
Declaration
public sealed override bool SourceColumnNullMapping { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
| Improve this DocSourceVersion
Declaration
public sealed override DataRowVersion SourceVersion { get; set; }
Property Value
Type | Description |
---|---|
DataRowVersion |
Overrides
| Improve this DocValue
Declaration
[TypeConverter(typeof(StringConverter))]
public override object Value { get; set; }
Property Value
Type | Description |
---|---|
Object |
Overrides
Methods
| Improve this DocClone()
Creates a new NpgsqlParameter that is a copy of the current instance.
Declaration
public NpgsqlParameter Clone()
Returns
Type | Description |
---|---|
NpgsqlParameter | A new NpgsqlParameter that is a copy of this instance. |
ResetDbType()
Declaration
public override void ResetDbType()
Overrides
Explicit Interface Implementations
| Improve this DocICloneable.Clone()
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
Object |