Class NpgsqlParameter
This class represents a parameter to a command that will be sent to server
Inheritance
Implements
Inherited Members
Namespace: Npgsql
Assembly: Npgsql.dll
Syntax
public sealed class NpgsqlParameter : DbParameter, IDbDataParameter, IDataParameter, ICloneable
Constructors
NpgsqlParameter()
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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the System.Data.DbType 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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
System.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
System.Int32 | size | The length of the parameter. |
System.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
NpgsqlDbType | parameterType | One of the NpgsqlDbType values. |
System.Int32 | size | The length of the parameter. |
System.String | sourceColumn | The name of the source column. |
System.Data.ParameterDirection | direction | One of the System.Data.ParameterDirection values. |
System.Boolean | isNullable | true if the value of the field can be null, otherwise false. |
System.Byte | precision | The total number of digits to the left and right of the decimal point to which Value is resolved. |
System.Byte | scale | The total number of decimal places to which Value is resolved. |
System.Data.DataRowVersion | sourceVersion | One of the System.Data.DataRowVersion values. |
System.Object | value | An System.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
System.Data.DbType | parameterType | One of the System.Data.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
System.Data.DbType | parameterType | One of the System.Data.DbType values. |
System.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
System.Data.DbType | parameterType | One of the System.Data.DbType values. |
System.Int32 | size | The length of the parameter. |
System.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
System.Data.DbType | parameterType | One of the System.Data.DbType values. |
System.Int32 | size | The length of the parameter. |
System.String | sourceColumn | The name of the source column. |
System.Data.ParameterDirection | direction | One of the System.Data.ParameterDirection values. |
System.Boolean | isNullable | true if the value of the field can be null, otherwise false. |
System.Byte | precision | The total number of digits to the left and right of the decimal point to which Value is resolved. |
System.Byte | scale | The total number of decimal places to which Value is resolved. |
System.Data.DataRowVersion | sourceVersion | One of the System.Data.DataRowVersion values. |
System.Object | value | An System.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 |
---|---|---|
System.String | parameterName | The name of the parameter to map. |
System.Object | value | An System.Object that is the value of the NpgsqlParameter. |
Remarks
When you specify an System.Object in the value parameter, the System.Data.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.
Declaration
public NpgsqlParameterCollection Collection { get; set; }
Property Value
Type | Description |
---|---|
NpgsqlParameterCollection |
DbType
Gets or sets the System.Data.DbType of the parameter.
Declaration
public override DbType DbType { get; set; }
Property Value
Type | Description |
---|---|
System.Data.DbType | One of the System.Data.DbType values. The default is Object. |
Overrides
Direction
Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.
Declaration
public override ParameterDirection Direction { get; set; }
Property Value
Type | Description |
---|---|
System.Data.ParameterDirection | One of the System.Data.ParameterDirection values. The default is Input. |
Overrides
EnumType
Used in combination with NpgsqlDbType.Enum or NpgsqlDbType.Array | NpgsqlDbType.Enum to indicate the enum type. For other NpgsqlDbTypes, this field is not used.
Declaration
[Obsolete("Use the SpecificType property instead")]
public Type EnumType { get; set; }
Property Value
Type | Description |
---|---|
System.Type |
IsNullable
Gets or sets a value that indicates whether the parameter accepts null values.
Declaration
public override bool IsNullable { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
NpgsqlDbType
Gets or sets the NpgsqlDbType of the parameter.
Declaration
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 |
---|---|
System.Object | An System.Object that is the value of the parameter. The default value is null. |
ParameterName
Gets or sets The name of the NpgsqlParameter.
Declaration
public override string ParameterName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the NpgsqlParameter. The default is an empty string. |
Overrides
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 |
---|---|
System.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 |
---|---|
System.Byte | The number of decimal places to which Value is resolved. The default is 0. |
Size
Gets or sets the maximum size, in bytes, of the data within the column.
Declaration
public override int Size { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The maximum size, in bytes, of the data within the column. The default value is inferred from the parameter value. |
Overrides
SourceColumn
Gets or sets The name of the source column that is mapped to the DataSet and used for loading or returning the Value.
Declaration
public override string SourceColumn { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the source column that is mapped to the DataSet. The default is an empty string. |
Overrides
SourceColumnNullMapping
Source column mapping.
Declaration
public override bool SourceColumnNullMapping { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
SourceVersion
Gets or sets the System.Data.DataRowVersion to use when loading Value.
Declaration
public override DataRowVersion SourceVersion { get; set; }
Property Value
Type | Description |
---|---|
System.Data.DataRowVersion | One of the System.Data.DataRowVersion values. The default is Current. |
Overrides
SpecificType
Used in combination with NpgsqlDbType.Enum or NpgsqlDbType.Composite to indicate the specific enum or composite type. For other NpgsqlDbTypes, this field is not used.
Declaration
public Type SpecificType { get; set; }
Property Value
Type | Description |
---|---|
System.Type |
Value
Gets or sets the value of the parameter.
Declaration
[TypeConverter(typeof(StringConverter))]
public override object Value { get; set; }
Property Value
Type | Description |
---|---|
System.Object | An System.Object that is the value of the parameter. The default value is null. |
Overrides
Methods
Clone()
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()
Reset DBType.
Declaration
public override void ResetDbType()
Overrides
Explicit Interface Implementations
ICloneable.Clone()
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
System.Object |