Search Results for

    Show / Hide Table of Contents

    Class NpgsqlParameter

    This class represents a parameter to a command that will be sent to server

    Inheritance
    object
    NpgsqlParameter
    NpgsqlParameter<T>
    Implements
    IDbDataParameter
    ICloneable
    Namespace: Npgsql
    Assembly: Npgsql.dll
    Syntax
    public class NpgsqlParameter : DbParameter, IDbDataParameter, ICloneable

    Constructors

    | Improve this Doc View Source

    NpgsqlParameter()

    Initializes a new instance of the NpgsqlParameter class.

    Declaration
    public NpgsqlParameter()
    | Improve this Doc View Source

    NpgsqlParameter(string?, DbType, int, 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 values.

    int size

    The length of the parameter.

    string? sourceColumn

    The name of the source column.

    | Improve this Doc View Source

    NpgsqlParameter(string?, DbType, int)

    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 values.

    int size

    The length of the parameter.

    | Improve this Doc View Source

    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 values.

    | Improve this Doc View Source

    NpgsqlParameter(string?, NpgsqlDbType, int, 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.

    int size

    The length of the parameter.

    string? sourceColumn

    The name of the source column.

    | Improve this Doc View Source

    NpgsqlParameter(string?, NpgsqlDbType, int)

    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.

    int size

    The length of the parameter.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    NpgsqlParameter(string?, object?)

    Initializes a new instance of the NpgsqlParameter class with the parameter name and a value.

    Declaration
    public NpgsqlParameter(string? parameterName, object? value)
    Parameters
    Type Name Description
    string? parameterName

    The name of the parameter to map.

    object? value

    The value of the NpgsqlParameter.

    Remarks

    When you specify an in the value parameter, the 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 for example to have compiler calling the correct constructor.

    | Improve this Doc View Source

    NpgsqlParameter(string, DbType, int, string?, ParameterDirection, bool, 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 values.

    int size

    The length of the parameter.

    string? sourceColumn

    The name of the source column.

    ParameterDirection direction

    One of the values.

    bool 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 values.

    object value

    An that is the value of the NpgsqlParameter.

    | Improve this Doc View Source

    NpgsqlParameter(string, NpgsqlDbType, int, string?, ParameterDirection, bool, 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.

    int size

    The length of the parameter.

    string? sourceColumn

    The name of the source column.

    ParameterDirection direction

    One of the values.

    bool 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 values.

    object value

    An that is the value of the NpgsqlParameter.

    Properties

    | Improve this Doc View Source

    Collection

    The collection to which this parameter belongs, if any.

    Declaration
    public NpgsqlParameterCollection? Collection { get; set; }
    Property Value
    Type Description
    NpgsqlParameterCollection
    | Improve this Doc View Source

    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?
    | Improve this Doc View Source

    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?
    | Improve this Doc View Source

    DbType

    Gets or sets the of the parameter.

    Declaration
    public override sealed DbType DbType { get; set; }
    Property Value
    Type Description
    DbType

    One of the values. The default is .

    | Improve this Doc View Source

    Direction

    Declaration
    public override sealed ParameterDirection Direction { get; set; }
    Property Value
    Type Description
    ParameterDirection
    | Improve this Doc View Source

    IsNullable

    Declaration
    public override sealed bool IsNullable { get; set; }
    Property Value
    Type Description
    bool
    | Improve this Doc View Source

    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 NpgsqlDbType.

    | Improve this Doc View Source

    NpgsqlValue

    Gets or sets the value of the parameter.

    Declaration
    public object? NpgsqlValue { get; set; }
    Property Value
    Type Description
    object?

    An that is the value of the parameter. The default value is null.

    | Improve this Doc View Source

    ParameterName

    Gets or sets The name of the NpgsqlParameter.

    Declaration
    public override sealed string ParameterName { get; set; }
    Property Value
    Type Description
    string

    The name of the NpgsqlParameter. The default is an empty string.

    | Improve this Doc View Source

    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.

    Declaration
    public PostgresType? PostgresType { get; }
    Property Value
    Type Description
    PostgresType
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    Size

    Declaration
    public override sealed int Size { get; set; }
    Property Value
    Type Description
    int
    | Improve this Doc View Source

    SourceColumn

    Declaration
    public override sealed string SourceColumn { get; set; }
    Property Value
    Type Description
    string
    | Improve this Doc View Source

    SourceColumnNullMapping

    Declaration
    public override sealed bool SourceColumnNullMapping { get; set; }
    Property Value
    Type Description
    bool
    | Improve this Doc View Source

    SourceVersion

    Declaration
    public override sealed DataRowVersion SourceVersion { get; set; }
    Property Value
    Type Description
    DataRowVersion
    | Improve this Doc View Source

    Value

    Declaration
    public override object? Value { get; set; }
    Property Value
    Type Description
    object?

    Methods

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    ResetDbType()

    Declaration
    public override void ResetDbType()

    Implements

    IDbDataParameter
    ICloneable
    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2023 The Npgsql Development Team