5.13.0-beta09 5.13.0-beta08 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 TimestampBound : IEquatable<TimestampBound>

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

Indicates how Spanner will choose a timestamp at which to read the data for read-only
transactions.

## Inheritance

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

## Implements

[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[TimestampBound](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound)

## Inherited Members

[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

## Properties

### Mode

    public TimestampBoundMode Mode { get; }

Indicates how to choose the timestamp at which to read the data for Cloud Spanner read-only transactions.
If your application can tolerate some staleness when reading data, you can use a stale read,
which can execute much faster when compared to reading the latest data.
The types of timestamp bounds are:
Strong (the default): read the latest data.
Bounded staleness: read a version of the data that's no staler than a bound.
Exact staleness: read the version of the data at an exact timestamp.

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

### ReturnReadTimestamp

    public bool ReturnReadTimestamp { get; }

If true, the read timestamp is included in the
Google.Cloud.Spanner.V1.Transaction message that describes the transaction.

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

### Staleness

    public TimeSpan Staleness { get; }

If [Mode](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_Mode) is [ExactStaleness](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_ExactStaleness) or
[MaxStaleness](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_MaxStaleness), this indicates the duration of time
for the staleness.

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

### Strong

    public static TimestampBound Strong { get; }

Read at a timestamp where all previously committed transactions
are visible.

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

### Timestamp

    public DateTime Timestamp { get; }

If [Mode](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_Mode) is [ReadTimestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_ReadTimestamp) or
[MinReadTimestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_MinReadTimestamp), this indicates the timestamp to use.

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

## Methods

### FromBase64String(string)

    public static TimestampBound FromBase64String(string base64String)

Creates an instance of [TimestampBound](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound) given its Base64 encoded string.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `base64String` | `https://learn.microsoft.com/dotnet/api/system.string` The string provided by [ToBase64String()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_ToBase64String). |

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

### GetHashCode()

    public override int GetHashCode()

Serves as the default hash function.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` | A hash code for the current object. |

**Overrides** [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)

### OfExactStaleness(TimeSpan)

    public static TimestampBound OfExactStaleness(TimeSpan duration)

Executes all reads at a timestamp that is `duration`
old. The timestamp is chosen soon after the read is started.

Guarantees that all writes that have committed more than the
specified number of seconds ago are visible. Because Cloud Spanner
chooses the exact timestamp, this mode works even if the client's
local clock is substantially skewed from Cloud Spanner commit
timestamps.

Useful for reading at nearby replicas without the distributed
timestamp negotiation overhead of [OfMaxStaleness(TimeSpan)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_OfMaxStaleness_System_TimeSpan_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://learn.microsoft.com/dotnet/api/system.timespan` The exact staleness to use. Must not be negative. |

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

### OfMaxStaleness(TimeSpan)

    public static TimestampBound OfMaxStaleness(TimeSpan duration)

Read data at a timestamp \>= `NOW - <code class="paramref">duration</code>`. Guarantees that all
writes that have committed more than the specified number of seconds ago are
visible.
Because Cloud Spanner chooses the exact timestamp, this mode works even if
the client's local clock is substantially skewed from Cloud Spanner
commit timestamps.

Useful for reading the freshest data available at a nearby
replica, while bounding the possible staleness if the local
replica has fallen behind.

Note that this option can only be used in single-use
transactions.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://learn.microsoft.com/dotnet/api/system.timespan` The maximum duration of staleness to use. Must not be negative. |

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

### OfMinReadTimestamp(DateTime)

    public static TimestampBound OfMinReadTimestamp(DateTime minReadTimestamp)

Executes all reads at a timestamp \>= `minReadTimestamp`.

This is useful for requesting fresher data than some previous
read, or data that is fresh enough to observe the effects of some
previously committed transaction whose timestamp is known.

Note that this option can only be used in single-use transactions

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `minReadTimestamp` | `https://learn.microsoft.com/dotnet/api/system.datetime` The earliest timestamp to read from. Must be in UTC. |

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

### OfReadTimestamp(DateTime)

    public static TimestampBound OfReadTimestamp(DateTime timestamp)

Executes all reads at the given timestamp. Unlike other modes,
reads at a specific timestamp are repeatable; the same read at
the same timestamp always returns the same data. If the
timestamp is in the future, the read will block until the
specified timestamp, modulo the read's deadline.

Useful for large scale consistent reads such as mapreduces, or
for coordinating many reads against a consistent snapshot of the
data.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timestamp` | `https://learn.microsoft.com/dotnet/api/system.datetime` The timestamp to read from. Must be in UTC. |

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

### ToBase64String()

    public string ToBase64String()

Returns a Base64 encoded string that can later be serialized back into a [TimestampBound](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound)
using [FromBase64String(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_FromBase64String_System_String_)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The base64 encoded string. |

### WithReturnReadTimestamp(bool)

    public TimestampBound WithReturnReadTimestamp(bool returnReadTimestamp)

Creates a [TimestampBound](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound) with the given value on
whether to return a read timestamp.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `returnReadTimestamp` | `https://learn.microsoft.com/dotnet/api/system.boolean` Whether to return a read timestamp. |

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