DatabaseConnectionRunInTransactionT Method (IDatabaseConnection, FuncIDatabaseConnection, T) |
Runs the function f in a transaction and returns the function result.
If the database is not currently in a transaction, a new transaction is created using
BeginTransaction with TransactionMode.Deferred and committed. Otherwise the transaction is created within
a savepoint block but not fully committed to the database until the enclosing transaction is committed.
Namespace: SQLitePCL.prettyAssembly: SQLitePCL.pretty (in SQLitePCL.pretty.dll) Version: 1.0.0.0 (1.0.0)
Syntax public static T RunInTransaction<T>(
this IDatabaseConnection This,
Func<IDatabaseConnection, T> f
)
[<ExtensionAttribute>]
static member RunInTransaction :
This : IDatabaseConnection *
f : Func<IDatabaseConnection, 'T> -> 'T
Parameters
- This
- Type: SQLitePCL.prettyIDatabaseConnection
The database connection. - f
- Type: SystemFuncIDatabaseConnection, T
The function to run in a transaction.
Type Parameters
- T
- The result type.
Return Value
Type:
TThe function result.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IDatabaseConnection. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Exceptions Exception | Condition |
---|
Exception | The exception that caused the transaction to be aborted and rolled back. |
See Also