# Google Cloud Spanner v1 API - Class ManagedSessionOptions (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 ManagedSessionOptions

Reference documentation and code samples for the Google Cloud Spanner v1 API class ManagedSessionOptions.

Options to used when creating a managed session.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ManagedSessionOptions

## Inherited Members

[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.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)

## Assembly

Google.Cloud.Spanner.V1.dll

## Properties

### Client

    public SpannerClient Client { get; }

The Spanner client to use for all operations associated to the session,
including session creation. Won't be null.

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

### DatabaseName

    public DatabaseName DatabaseName { get; }

The database for which the session will be created. Won't be null.

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

### DatabaseRole

    public string DatabaseRole { get; }

The database role with which the session will be created. May be null,
in which case the default (public) database role is used if fine grained access control
is enabled; otherwise the database role is ignored.

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

### Timeout

    public TimeSpan? Timeout { get; }

The total time allowed for a network call to the Cloud Spanner server, including retries. This setting
is applied to calls to create sessions, as well as explicitly beginning transactions. May be null,
in which case 1 minute will be used. Otherwise, the value will be positive.

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

## Methods

### Create(DatabaseName, SpannerClient)

    public static ManagedSessionOptions Create(DatabaseName databaseName, SpannerClient client)

Creates a [ManagedSessionOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedSessionOptions) with the given database name.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `databaseName` | `Google.Cloud.Spanner.Common.V1.DatabaseName` The database name for the associated session. Must not be null. |
| `client` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerClient` The Spanner client that the sessions will use for all command execution, including those executed by associated [ManagedTransaction](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedTransaction). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedSessionOptions` |   |

### WithDatabaseRole(string)

    public ManagedSessionOptions WithDatabaseRole(string databaseRole)

Creates a [ManagedSessionOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedSessionOptions) based on this one but with the given database role.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `databaseRole` | `https://learn.microsoft.com/dotnet/api/system.string` The database role for the associated session. May be null in which case the default (public) database role is used if fine grained access control is enabled; otherwise the database role is ignored. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedSessionOptions` |   |

### WithTimeout(TimeSpan?)

    public ManagedSessionOptions WithTimeout(TimeSpan? timeout)

Creates a [ManagedSessionOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedSessionOptions) based on this one but with the given timeout.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `https://learn.microsoft.com/dotnet/api/system.timespan` The total time allowed for a network call to the Cloud Spanner server, including retries. This setting is applied to calls to create sessions, as well as explicitly beginning transactions. May be null, in which case 1 minute will be used. Otherwise, the value must be positive. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ManagedSessionOptions` |   |