> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# TursoTransaction

> Represents a database transaction that can be committed or rolled back.             Implements IAsyncDisposable for automatic rollback if not committed.

## Definition

**Assembly:** CloudNimble.BlazorEssentials.TursoDb.dll

**Namespace:** CloudNimble.BlazorEssentials.TursoDb

**Inheritance:** System.Object

## Syntax

```csharp theme={"dark"}
CloudNimble.BlazorEssentials.TursoDb.TursoTransaction
```

## Summary

Represents a database transaction that can be committed or rolled back.
Implements IAsyncDisposable for automatic rollback if not committed.

## Examples

```csharp theme={"dark"}
await using var transaction = await Database.BeginTransactionAsync();
try
{
    await Database.Users.AddAsync(user);
    await Database.Posts.AddAsync(post);
    await transaction.CommitAsync();
}
catch
{
    await transaction.RollbackAsync();
    throw;
}
```

## Constructors

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Properties

### &#x20;Database

Gets the database this transaction belongs to.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.BlazorEssentials.TursoDb.TursoDatabase Database { get; }
```

#### Property Value

Type: `CloudNimble.BlazorEssentials.TursoDb.TursoDatabase`

### &#x20;IsCompleted

Gets whether the transaction has been completed (committed or rolled back).

#### Syntax

```csharp theme={"dark"}
public bool IsCompleted { get; }
```

#### Property Value

Type: `bool`

## Methods

### &#x20;CommitAsync

Commits the transaction, making all changes permanent.

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task CommitAsync()
```

#### Returns

Type: `System.Threading.Tasks.Task`

#### Exceptions

| Exception | Description |
| - | - |
| `InvalidOperationException` | Thrown if the transaction is already completed. |

### &#x20;DisposeAsync

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.ValueTask DisposeAsync()
```

#### Returns

Type: `System.Threading.Tasks.ValueTask`

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;RollbackAsync

Rolls back the transaction, discarding all changes.

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task RollbackAsync()
```

#### Returns

Type: `System.Threading.Tasks.Task`

#### Exceptions

| Exception | Description |
| - | - |
| `InvalidOperationException` | Thrown if the transaction is already completed. |

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

## Related APIs

* System.IAsyncDisposable


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.