# Google.Cloud.Spanner.Data - Class SpannerParameter (5.13.0-beta07)

5.13.0-beta07 5.13.0-beta06 5.12.0 (latest) 5.11.0 5.10.0 5.9.0 5.8.0 5.7.0 5.6.0 5.5.0 5.4.0 5.3.0 5.2.0 5.1.0 5.0.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.15.1 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0

    public sealed class SpannerParameter : DbParameter, IDbDataParameter, IDataParameter, ICloneable

Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerParameter.

Represents a parameter to a [SpannerCommand](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerCommand) and optionally its mapping to DataSet columns.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [MarshalByRefObject](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject) \> [DbParameter](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter) \> SpannerParameter

## Implements

[IDbDataParameter](https://learn.microsoft.com/dotnet/api/system.data.idbdataparameter), [IDataParameter](https://learn.microsoft.com/dotnet/api/system.data.idataparameter), [ICloneable](https://learn.microsoft.com/dotnet/api/system.icloneable)

## Inherited Members

[DbParameter.Precision](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.precision) [DbParameter.Scale](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.scale) [MarshalByRefObject.GetLifetimeService()](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject.getlifetimeservice) [MarshalByRefObject.InitializeLifetimeService()](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject.initializelifetimeservice) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Spanner.Data](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data)

## Assembly

Google.Cloud.Spanner.Data.dll

## Constructors

### SpannerParameter()

    public SpannerParameter()

Initializes a new instance of the SpannerParameter class.

### SpannerParameter(string, SpannerDbType, object, string)

    public SpannerParameter(string parameterName, SpannerDbType type, object value = null, string sourceColumn = null)

Initializes a new instance of the SpannerParameter class.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parameterName` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the parameter. For Insert, Update and Delete commands, this name should be the name of a valid column in a Spanner table. In Select commands, this name should be the name of a parameter used in the SQL Query. This value is case sensitive. Must not be null. |
| `type` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType` One of the [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter#Google_Cloud_Spanner_Data_SpannerParameter_SpannerDbType) values that indicates the type of the parameter. Must not be null. |
| `value` | `https://learn.microsoft.com/dotnet/api/system.object` An object that is the value of the SpannerParameter. May be null. |
| `sourceColumn` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the DataTable source column (SourceColumn) if this SpannerParameter is used in a call to Update. May be null. |

## Properties

### CommitTimestamp

    public static object CommitTimestamp { get; }

Returns a value that will be replaced with a commit timestamp on insert or update.
Only suitable for [Timestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Timestamp) values.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` |   |

### DbType

    public override DbType DbType { get; set; }

Specifies the data type of a field, a property, or a Parameter object of a .NET
Framework data provider.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.data.dbtype` |   |

**Overrides** [DbParameter.DbType](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.dbtype) **Remarks** Using DbType of VarNumeric will always default to SpannerDbType of SpannerNumeric and never to PgNumeric.

### Direction

    public override ParameterDirection Direction { get; set; }

Gets or sets a value that indicates whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.data.parameterdirection` | One of the [ParameterDirection](https://learn.microsoft.com/dotnet/api/system.data.parameterdirection) values. The default is `Input`. |

**Overrides** [DbParameter.Direction](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.direction)

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.argumentexception` | The property is not set to one of the valid [ParameterDirection](https://learn.microsoft.com/dotnet/api/system.data.parameterdirection) values. |

### IsNullable

    public override bool IsNullable { get; set; }

Gets or sets a value that indicates whether the parameter accepts null values.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if null values are accepted; otherwise [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). The default is [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

**Overrides** System.Data.Common.DbParameter.IsNullable

### ParameterName

    public override string ParameterName { get; set; }

Gets or sets the name of the [DbParameter](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The name of the [DbParameter](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter). The default is an empty string (""). |

**Overrides** [DbParameter.ParameterName](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.parametername)

### Size

    public override int Size { get; set; }

Gets or sets the maximum size, in bytes, of the data within the column.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` | The maximum size, in bytes, of the data within the column. The default value is inferred from the parameter value. |

**Overrides** [DbParameter.Size](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.size)

### SourceColumn

    public override string SourceColumn { get; set; }

Gets or sets the name of the source column mapped to the [DataSet](https://learn.microsoft.com/dotnet/api/system.data.dataset) and used for loading or returning the [Value](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.value).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The name of the source column mapped to the [DataSet](https://learn.microsoft.com/dotnet/api/system.data.dataset). The default is an empty string. |

**Overrides** [DbParameter.SourceColumn](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.sourcecolumn)

### SourceColumnNullMapping

    public override bool SourceColumnNullMapping { get; set; }

Sets or gets a value which indicates whether the source column is nullable. This allows [DbCommandBuilder](https://learn.microsoft.com/dotnet/api/system.data.common.dbcommandbuilder) to correctly generate Update statements for nullable columns.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the source column is nullable; [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if it is not. |

**Overrides** [DbParameter.SourceColumnNullMapping](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.sourcecolumnnullmapping)

### SourceVersion

    public override DataRowVersion SourceVersion { get; set; }

Gets or sets the [DataRowVersion](https://learn.microsoft.com/dotnet/api/system.data.datarowversion) to use when you load [Value](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.value).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.data.datarowversion` | One of the [DataRowVersion](https://learn.microsoft.com/dotnet/api/system.data.datarowversion) values. The default is `Current`. |

**Overrides** [DbParameter.SourceVersion](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.sourceversion)

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.argumentexception` | The property is not set to one of the [DataRowVersion](https://learn.microsoft.com/dotnet/api/system.data.datarowversion) values. |

### SpannerDbType

    public SpannerDbType SpannerDbType { get; set; }

The [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter#Google_Cloud_Spanner_Data_SpannerParameter_SpannerDbType) of the parameter or column. This should match the type as defined in Spanner
or as defined by the result of a SQL Query.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType` |   |

### Value

    public override object Value { get; set; }

Gets or sets the value of the parameter.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` | An [object](https://learn.microsoft.com/dotnet/api/system.object) that is the value of the parameter. The default value is null. |

**Overrides** [DbParameter.Value](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.value)

## Methods

### Clone()

    public object Clone()

Creates a new object that is a copy of the current instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` | A new object that is a copy of this instance. |

### ResetDbType()

    public override void ResetDbType()

Resets the DbType property to its original settings.
**Overrides** [DbParameter.ResetDbType()](https://learn.microsoft.com/dotnet/api/system.data.common.dbparameter.resetdbtype)