# Google.Cloud.Spanner.Data - Class SpannerConnectionStringBuilder (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 SpannerConnectionStringBuilder : DbConnectionStringBuilder, IDictionary, ICollection, IEnumerable, ICustomTypeDescriptor

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

A connection string builder for Spanner connection strings.
The connection string should be of the form:
Data Source=projects/{project}/instances/{instance}/databases/{database};\[Host={hostname};\]\[Port={portnumber}\]

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [DbConnectionStringBuilder](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder) \> SpannerConnectionStringBuilder

## Implements

[IDictionary](https://learn.microsoft.com/dotnet/api/system.collections.idictionary), [ICollection](https://learn.microsoft.com/dotnet/api/system.collections.icollection), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable), [ICustomTypeDescriptor](https://learn.microsoft.com/dotnet/api/system.componentmodel.icustomtypedescriptor)

## Inherited Members

[DbConnectionStringBuilder.Add(string, object)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.add) [DbConnectionStringBuilder.AppendKeyValuePair(StringBuilder, string, string)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.appendkeyvaluepair#system-data-common-dbconnectionstringbuilder-appendkeyvaluepair(system-text-stringbuilder-system-string-system-string)) [DbConnectionStringBuilder.AppendKeyValuePair(StringBuilder, string, string, bool)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.appendkeyvaluepair#system-data-common-dbconnectionstringbuilder-appendkeyvaluepair(system-text-stringbuilder-system-string-system-string-system-boolean)) [DbConnectionStringBuilder.ContainsKey(string)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.containskey) [DbConnectionStringBuilder.EquivalentTo(DbConnectionStringBuilder)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.equivalentto) [DbConnectionStringBuilder.Remove(string)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.remove) [DbConnectionStringBuilder.ShouldSerialize(string)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.shouldserialize) [DbConnectionStringBuilder.ToString()](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.tostring) [DbConnectionStringBuilder.TryGetValue(string, out object)](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.trygetvalue) [DbConnectionStringBuilder.ConnectionString](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.connectionstring) [DbConnectionStringBuilder.Count](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.count) [DbConnectionStringBuilder.IsFixedSize](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.isfixedsize) [DbConnectionStringBuilder.IsReadOnly](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.isreadonly) [DbConnectionStringBuilder.Keys](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.keys) [DbConnectionStringBuilder.Values](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.values) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)

## 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

### SpannerConnectionStringBuilder()

    public SpannerConnectionStringBuilder()

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

### SpannerConnectionStringBuilder(string, GoogleCredential)

    public SpannerConnectionStringBuilder(string connectionString, GoogleCredential googleCredential)

Creates a new [SpannerConnectionStringBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder) with the given
connection string and optional credential.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `connectionString` | `https://learn.microsoft.com/dotnet/api/system.string` A connection string of the form Data Source=projects/{project}/instances/{instance}/databases/{database};\[Host={hostname};\]\[Port={portnumber}\]. |
| `googleCredential` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.GoogleCredential.html` The credential to use for the connection. If this is null, then default application credentials will be used. Credentials can be retrieved from a file or obtained interactively. See Google Cloud documentation for more information. May be null. |

### SpannerConnectionStringBuilder(string, ChannelCredentials)

    public SpannerConnectionStringBuilder(string connectionString, ChannelCredentials credentials = null)

Creates a new [SpannerConnectionStringBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder) with the given
connection string and optional credential.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `connectionString` | `https://learn.microsoft.com/dotnet/api/system.string` A connection string of the form Data Source=projects/{project}/instances/{instance}/databases/{database};\[Host={hostname};\]\[Port={portnumber}\]. Must not be null. |
| `credentials` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ChannelCredentials.html` Optionally supplied credential to use for the connection. If this is null (the default parameter value), then default application credentials will be used. Credentials can be retrieved from a file or obtained interactively. See Google Cloud documentation for more information. |

## Properties

### AllowImmediateTimeouts

    public bool AllowImmediateTimeouts { get; set; }

Option to allow a timeout of 0 to mean "fail immediately" rather than "continue indefinitely".
This is primarily used for testing.

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

### ClrToSpannerTypeDefaultMappings

    public string ClrToSpannerTypeDefaultMappings { get; set; }

Option to configure the default CLR type to SpannerDbType mapping. This option comes into picture
only if [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType) and [DbType](https://learn.microsoft.com/dotnet/api/system.data.dbtype) of the [SpannerParameter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter)
are not explicitly provided. Currently only [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) and [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) CLR types are supported.

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

**Remarks** The valid type mappings for decimal are:

`DecimalToFloat64` - [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) CLR type will map to [Float64](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Float64),
if [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType) and [DbType](https://learn.microsoft.com/dotnet/api/system.data.dbtype) is not explicitly provided for the [SpannerParameter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter).

`DecimalToNumeric` - [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) CLR type will map to [Numeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Numeric),
if [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType) and [DbType](https://learn.microsoft.com/dotnet/api/system.data.dbtype) is not explicitly provided for the [SpannerParameter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter).
This should be used while working with Google Standard SQL dialect only.

`DecimalToPgNumeric` - [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) CLR type will map to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_PgNumeric),
if [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType) and [DbType](https://learn.microsoft.com/dotnet/api/system.data.dbtype) is not explicitly provided for the [SpannerParameter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter).
This should be used while working with PostgreSQL dialect only.

The valid type mappings for DateTime are:

`DateTimeToDate` - [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) CLR type will map to [Date](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Date),
if [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType) and [DbType](https://learn.microsoft.com/dotnet/api/system.data.dbtype) is not explicitly provided for the [SpannerParameter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter).

`DateTimeToTimestamp` - [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) CLR type will map to [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),
if [SpannerDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType) and [DbType](https://learn.microsoft.com/dotnet/api/system.data.dbtype) is not explicitly provided for the [SpannerParameter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerParameter).

The mapping can be provided as comma separated values. Only one mapping for a type must be provided.
Providing mutiple mapping for a type, or providing invalid mapping or providing whitespaces will result in [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception). Few examples of valid values are:


DecimalToFloat64,DateTimeToDate


DecimalToNumeric,DateTimeToTimestamp


This property corresponds with the value of the "ClrToSpannerTypeDefaultMappings" part of the connection string.

### CredentialFile

    public string CredentialFile { get; set; }

Optional path to a JSON Credential file. If a Credential is not supplied, Cloud Spanner
will use Default Application Credentials.

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

### DataSource

    public string DataSource { get; set; }

DataSource of the Spanner database in the form of 'projects/{project}/instances/{instance}/databases/{database}'
or 'projects/{project}/instances/{instance}'.

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

### DatabaseName

    public DatabaseName DatabaseName { get; set; }

The fully-qualified database name parsed from [DataSource](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_DataSource).
May be null, if the data source isn't set, or is invalid, or doesn't contain a database name.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `Google.Cloud.Spanner.Common.V1.DatabaseName` |   |

### DatabaseRole

    public string DatabaseRole { get; set; }

The database role for the sessions created by this connection.

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

### DirectedReadOptions

    public DirectedReadOptions DirectedReadOptions { get; set; }

Specifies which replicas or regions should be used for non-transactional reads or queries. May be null.
When set, all queries and reads executed on this connection within a read-only or single-use transaction
will include these options. If a query or read command specifies directed read options itself
then those have precedence over these.
For other operations or for non read-only or single-use transactions, these options are ignored.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `Google.Cloud.Spanner.V1.DirectedReadOptions` |   |

**Remarks** These options are not settable through the connection string actual string value.
Instead they are only settable via code on [SpannerConnectionStringBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder) instances.
This may change in the future and directed read options may be made available through the actual string
value of the connection string.

### EmulatorDetection

    public EmulatorDetection EmulatorDetection { get; set; }

Specifies whether to allow the connection to check for the presence of the emulator
environment variable.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.EmulatorDetection.html` |   |

**Remarks** This property defaults to [None](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.EmulatorDetection.html#Google_Api_Gax_EmulatorDetection_None), meaning that the
environment variable is ignored.

### EnableGetSchemaTable

    public bool EnableGetSchemaTable { get; set; }

Option to allow [SpannerDataReader](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDataReader) to return a schema from `GetSchemaTable`, on supported platforms.
Only partial information is available, and when this option is enabled, `DbDataAdapter` may be overly eager to
use the information to create and manage datasets.

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

### EnableLeaderRouting

    public bool EnableLeaderRouting { get; set; }

Options to control leader routing. This is true by default.

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

**Remarks** If this value is true some operations will always be explicitly routed to the leader,
some operations will never be explicitly routed to the leader, and some operations will
be routed to the leader depending on the transaction type they are using.

### EndPoint

    public string EndPoint { get; }

The endpoint to use to connect to Spanner. If not supplied in the
connection string, the default endpoint will be used.

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

### Host

    public string Host { get; set; }

The TCP Host name to connect to Spanner. If not supplied in the connection string, the default
host will be used.

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

### IsolationLevel

    public IsolationLevel IsolationLevel { get; set; }

Option to set the default for [IsolationLevel](https://learn.microsoft.com/dotnet/api/system.data.isolationlevel) for all transactions executed on this connection.
Override on a per-transaction basis using [SpannerTransactionCreationOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionCreationOptions).

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

### this\[string\]

    public override object this[string keyword] { get; set; }

Gets or sets the value associated with the specified key.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `keyword` | `https://learn.microsoft.com/dotnet/api/system.string` The key of the item to get or set. |

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` | The value associated with the specified key. If the specified key is not found, trying to get it returns a null reference (`Nothing` in Visual Basic), and trying to set it creates a new element using the specified key. Passing a null (`Nothing` in Visual Basic) key throws an [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception). Assigning a null value removes the key/value pair. |

**Overrides** [DbConnectionStringBuilder.this\[string\]](https://learn.microsoft.com/dotnet/api/system.string)

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.argumentnullexception` | `keyword` is a null reference (`Nothing` in Visual Basic). |
| `https://learn.microsoft.com/dotnet/api/system.notsupportedexception` | The property is set, and the [DbConnectionStringBuilder](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder) is read-only. -or- The property is set, `keyword` does not exist in the collection, and the [DbConnectionStringBuilder](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder) has a fixed size. |

### LogCommitStats

    public bool LogCommitStats { get; set; }

Request commit statistics for all read/write transactions throughout the
lifetime of the connection and log these.

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

**Remarks** Commit statistics that are returned for a transaction are logged using the
logger of the connection. Applications can set a custom logger on the
connection to log the output to a different destination.
Google.Cloud.Spanner.V1.Internal.Logging.Logger.LogCommitStats(Google.Cloud.Spanner.V1.CommitRequest, Google.Cloud.Spanner.V1.CommitResponse)

### MaxConcurrentStreamsLowWatermark

    public int MaxConcurrentStreamsLowWatermark { get; set; }

The low watermark of max number of concurrent streams in a channel.
A new channel will be created once this is reached, until the maximum size
of the channel pool is reached. This rarely needs to be modified.

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

### MaximumGrpcChannels

    public int MaximumGrpcChannels { get; set; }

The maximum number of gRPC channels used for connections with the same settings.
Defaults to 4.

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

### Port

    public int Port { get; set; }

The TCP port number to connect to Spanner. If not supplied in the connection string, the default
port will be used.

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

### Project

    public string Project { get; }

The Spanner Project name parsed from [DataSource](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_DataSource)
May be null, if the data source isn't set, or is invalid.

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

### SessionPoolManager

    public SessionPoolManager SessionPoolManager { get; set; }

The [SessionPoolManager](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_SessionPoolManager) to use for server interactions.

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

**Remarks** This property defaults to [Default](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SessionPoolManager#Google_Cloud_Spanner_Data_SessionPoolManager_Default), and
most code will not need to change this. It can be convenient for isolation purposes,
particularly in testing.

### SpannerDatabase

    public string SpannerDatabase { get; }

The Spanner Database name parsed from [DataSource](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_DataSource).
May be null, if the data source isn't set, or is invalid, or doesn't contain a database name.

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

### SpannerInstance

    public string SpannerInstance { get; }

The Spanner Instance name parsed from [DataSource](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_DataSource)
May be null, if the data source isn't set, or is invalid.

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

### SpannerToClrTypeDefaultMappings

    public string SpannerToClrTypeDefaultMappings { get; set; }

Option to configure the default SpannerDbType to CLR type mappings. This option comes into picture
only if CLR type of the value being read is not explicitly provided while reading the data from the database.
Currently only [Date](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Date) is supported.

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

**Remarks** The valid type mappings for Date are:


`DateToDateTime` - [Date](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Date) will map to [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime),
if CLR type of the value being read is not explicitly provided.


`DateToSpannerDate` - [Date](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType#Google_Cloud_Spanner_Data_SpannerDbType_Date) will map to Google.Cloud.Spanner.V1.SpannerDate,
if CLR type of the value being read is not explicitly provided.

The mapping can be provided as comma separated values. Only one mapping for a SpannerDbType must be provided.
Providing mutiple mapping for a type, or providing invalid mapping or providing whitespaces will result in [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception).
Few examples of valid values are:


DateToDateTime


DateToSpannerDate


This property corresponds with the value of the "SpannerToClrTypeDefaultMappings" part of the connection string.

### Timeout

    public int Timeout { get; set; }

Defines the default values for [CommandTimeout](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerCommand#Google_Cloud_Spanner_Data_SpannerCommand_CommandTimeout) and
transaction commits along with all network operations to a Cloud Spanner database.
Defaults to 60 seconds.

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

**Remarks** Operations sent to the server that take greater than this duration will fail
with a [SpannerException](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerException) and error code [DeadlineExceeded](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.ErrorCode#Google_Cloud_Spanner_Data_ErrorCode_DeadlineExceeded).
A value of '0' normally indicates that no timeout should be used (it waits an infinite amount of time).
However, if you specify AllowImmediateTimeouts=true in the connection string, '0' will cause a timeout
that expires immediately. This is normally used only for testing purposes.

### UniverseDomain

    public string UniverseDomain { get; set; }

The universe domain to connect to, or null to use the default universe domain Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder.DefaultDomain.

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

**Remarks**
[UniverseDomain](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_UniverseDomain) is used to build the endpoint to connect to, unless [EndPoint](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_EndPoint) or [Host](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_Host)
are explicitly set, in which case [EndPoint](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_EndPoint) will be used without further modification.


If default credentials or one of Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder.GoogleCredential or [CredentialFile](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_CredentialFile)
is used, [GetUniverseDomain()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.GoogleCredential.html#Google_Apis_Auth_OAuth2_GoogleCredential_GetUniverseDomain) should be:
The same as [UniverseDomain](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_UniverseDomain) if [UniverseDomain](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder#Google_Cloud_Spanner_Data_SpannerConnectionStringBuilder_UniverseDomain) has been set otherwise should be same as Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder.DefaultDomain

### UseClrDefaultForNull

    public bool UseClrDefaultForNull { get; set; }

Option to change between the default handling of null database values (return [DBNull.Value](https://learn.microsoft.com/dotnet/api/system.dbnull.value)) or
the non-standard handling (return the default value for whatever type is requested).

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

**Remarks**
If this is `false` (the default), requesting a value from a [SpannerDataReader](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDataReader) that is null
in the database will return [DBNull.Value](https://learn.microsoft.com/dotnet/api/system.dbnull.value), which may cause an [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception) if
the requested type is not compatible with that value. For arrays and structs, the behavior is slightly different.
A null value is used for an array or struct value where the target type permits such a value. Attempting to convert
an array value that contains a null element into a .NET array type with a non-nullable element type will
cause an [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception) to be thrown. To avoid this, where array elements may be null for value types,
use an array with a nullable element type. This allows code to distinguish between a null element in the original
data and a value of 0, false etc.


If this is `true`, requesting a value from a [SpannerDataReader](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDataReader) that is null in the
database will return the default value of the requested type (e.g. 0 or a null reference). That conversion is also used for
array elements. For example, converting a Spanner array consisting of 1, null, and 2 into an `Int32` array will result in
an array containing 1, 0 and 2. This is the behavior from release 1.0 of this package.


This property corresponds with the value of the "UseClrDefaultForNull" part of the connection string.

## Methods

### Clear()

    public override void Clear()

Clears the contents of the [DbConnectionStringBuilder](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder) instance.
**Overrides** [DbConnectionStringBuilder.Clear()](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder.clear)

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.notsupportedexception` | The [DbConnectionStringBuilder](https://learn.microsoft.com/dotnet/api/system.data.common.dbconnectionstringbuilder) is read-only. |

### WithDatabase(string)

    public SpannerConnectionStringBuilder WithDatabase(string database)

Returns a new instance of a [SpannerConnectionStringBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder) with the database
portion of the DataSource replaced with a new value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` The new database name. Can be null to open a connection for Ddl commands. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder` | A new instance of [SpannerConnectionStringBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerConnectionStringBuilder) |