Transactions allow you to execute a group of queries atomically, meaning either all changes are applied or none are. This is essential for maintaining data consistency when performing related operations that must not be partially applied.
| Method | Description |
|---|---|
session.BeginTransaction()
| Create a new transaction scoped to the current session. |
txn.Commit()
| Commit the transaction to the database, applying all changes made within the transaction scope. |
txn.Cancel()
| Cancel and discard all changes made in the transaction. |
.BeginTransaction()
Creates a new transaction scoped to the current session. Transactions allow you to execute multiple queries atomically.
Arguments
| Arguments | Description |
|---|---|
cancellationToken
| The cancellationToken enables graceful cancellation of asynchronous operations. |
Example usage
.Commit()
Commits the transaction to the database, applying all changes made within the transaction scope.
Note
Arguments
| Arguments | Description |
|---|---|
cancellationToken
| The cancellationToken enables graceful cancellation of asynchronous operations. |
Example usage
.Cancel()
Cancels and discards all changes made in the transaction.
Note
Arguments
| Arguments | Description |
|---|---|
cancellationToken
| The cancellationToken enables graceful cancellation of asynchronous operations. |