Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Dal.Transaction< TC > Class Template Reference

Database Transactions More...

Static Public Member Functions

static Task< T > Distributed< T > (ILogger logger, Func< Task< TransactionResponse< T >>> method)
 Wrapper for multiple Sql calls across multiple databases within a transaction More...
 
static Task< T > Distributed< T > (ILogger logger, Func< Task< TransactionResponse< T >>> method, T defaultValue)
 Wrapper for multiple Sql calls across multiple databases within a transaction More...
 
static async Task< T > Distributed< T > (ILogger logger, Func< Task< TransactionResponse< T >>> method, Func< Exception, T, T > exceptionMethod, T defaultValue=default)
 Wrapper for multiple Sql calls across multiple databases within a transaction More...
 
static Task< T > Run< T > (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse< T >>> method)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static Task< T > Run< T > (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse< T >>> method, T defaultValue)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static Task< T > Run< T > (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse< T >>> method, IsolationLevel isolation)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static Task< T > Run< T > (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse< T >>> method, IsolationLevel isolation, T defaultValue)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static Task< T > Run< T > (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse< T >>> method, Func< Exception, T, T > exceptionMethod, T defaultValue=default)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static async Task< T > Run< T > (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse< T >>> method, IsolationLevel isolation, Func< Exception, T, T > exceptionMethod, T defaultValue=default)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static async Task< bool > Distributed (ILogger logger, Func< Task< TransactionResponse >> method, Func< Exception, bool > exceptionMethod=null)
 Wrapper for multiple Sql calls across multiple databases within a transaction More...
 
static Task< bool > Run (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse >> method, Func< Exception, bool > exceptionMethod=null)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static Task< bool > Run (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse >> method, IsolationLevel isolation)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static async Task< bool > Run (ILogger logger, string cnnStr, Func< IDbTransaction, Task< TransactionResponse >> method, IsolationLevel isolation, Func< Exception, bool > exceptionMethod)
 Wrapper for multiple Sql calls (Single database) within a transaction More...
 
static bool ExceptionRethrow (Exception ex)
 Use this method as parameter for Sql().exceptionMethod More...
 
static T ExceptionDefaultVal< T > (Exception ex, T defaultValue)
 Use this method as parameter for Sql().exceptionMethod More...
 
static T ExceptionRethrow< T > (Exception ex, T defaultValue)
 Use this method as parameter for Sql().exceptionMethod More...
 

Detailed Description

Database Transactions

Type Constraints
TC :DbConnection 
TC :new() 

Member Function Documentation

◆ Distributed()

static async Task<bool> Sphyrnidae.Common.Dal.Transaction< TC >.Distributed ( ILogger  logger,
Func< Task< TransactionResponse >>  method,
Func< Exception, bool >  exceptionMethod = null 
)
static

Wrapper for multiple Sql calls across multiple databases within a transaction

This will use individual connections using a distributed transactions (performance hit)

Parameters
loggerThe logger for the transaction sequence
methodThe actual SQL calls
exceptionMethodDefault = ExceptionRethrow. If an exception is thrown during "method", how will it be handled (besides being rolled back)
Returns
True if the transaction was committed, false if rolled back

◆ Distributed< T >() [1/3]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Distributed< T > ( ILogger  logger,
Func< Task< TransactionResponse< T >>>  method 
)
static

Wrapper for multiple Sql calls across multiple databases within a transaction

This will use individual connections using a distributed transactions (performance hit)

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
methodThe actual SQL calls
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Distributed< T >() [2/3]

static async Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Distributed< T > ( ILogger  logger,
Func< Task< TransactionResponse< T >>>  method,
Func< Exception, T, T >  exceptionMethod,
defaultValue = default 
)
static

Wrapper for multiple Sql calls across multiple databases within a transaction

This will use individual connections using a distributed transactions (performance hit)

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
methodThe actual SQL calls
exceptionMethodDefault = ExceptionRethrow. If an exception is thrown during "method", how will it be handled (besides being rolled back)
defaultValueDefault = Default(T). If an exception is thrown during "method", and it is not rethrowing the exception, this will instead be returned
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Distributed< T >() [3/3]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Distributed< T > ( ILogger  logger,
Func< Task< TransactionResponse< T >>>  method,
defaultValue 
)
static

Wrapper for multiple Sql calls across multiple databases within a transaction

This will use individual connections using a distributed transactions (performance hit)

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
methodThe actual SQL calls
defaultValueDefault = Default(T). If an exception is thrown during "method", and it is not rethrowing the exception, this will instead be returned
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ ExceptionDefaultVal< T >()

static T Sphyrnidae.Common.Dal.Transaction< TC >.ExceptionDefaultVal< T > ( Exception  ex,
defaultValue 
)
static

Use this method as parameter for Sql().exceptionMethod

Template Parameters
TReturn type
Parameters
exException that was thrown
defaultValueThe default return value
Returns
defaultValue

◆ ExceptionRethrow()

static bool Sphyrnidae.Common.Dal.Transaction< TC >.ExceptionRethrow ( Exception  ex)
static

Use this method as parameter for Sql().exceptionMethod

Parameters
exException that was thrown
Returns
Nothing - will rethrow

◆ ExceptionRethrow< T >()

static T Sphyrnidae.Common.Dal.Transaction< TC >.ExceptionRethrow< T > ( Exception  ex,
defaultValue 
)
static

Use this method as parameter for Sql().exceptionMethod

Template Parameters
TReturn type (unused)
Parameters
exException that was thrown
defaultValueThe default return value (unused)
Returns
Nothing - will rethrow

◆ Run() [1/3]

static Task<bool> Sphyrnidae.Common.Dal.Transaction< TC >.Run ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse >>  method,
Func< Exception, bool >  exceptionMethod = null 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
exceptionMethodDefault = ExceptionRethrow. If an exception is thrown during "method", how will it be handled (besides being rolled back)
Returns
True if the transaction was committed, false if rolled back

◆ Run() [2/3]

static Task<bool> Sphyrnidae.Common.Dal.Transaction< TC >.Run ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse >>  method,
IsolationLevel  isolation 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
isolationDefault = ReadCommitted. Isolation level for the transaction.
Returns
True if the transaction was committed, false if rolled back

◆ Run() [3/3]

static async Task<bool> Sphyrnidae.Common.Dal.Transaction< TC >.Run ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse >>  method,
IsolationLevel  isolation,
Func< Exception, bool >  exceptionMethod 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
isolationDefault = ReadCommitted. Isolation level for the transaction.
exceptionMethodDefault = ExceptionRethrow. If an exception is thrown during "method", how will it be handled (besides being rolled back)
Returns
True if the transaction was committed, false if rolled back

◆ Run< T >() [1/6]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Run< T > ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse< T >>>  method 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Run< T >() [2/6]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Run< T > ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse< T >>>  method,
Func< Exception, T, T >  exceptionMethod,
defaultValue = default 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
exceptionMethodDefault = ExceptionRethrow. If an exception is thrown during "method", how will it be handled (besides being rolled back)
defaultValueDefault = Default(T). If an exception is thrown during "method", and it is not rethrowing the exception, this will instead be returned
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Run< T >() [3/6]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Run< T > ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse< T >>>  method,
IsolationLevel  isolation 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
isolationDefault = ReadCommitted. Isolation level for the transaction.
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Run< T >() [4/6]

static async Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Run< T > ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse< T >>>  method,
IsolationLevel  isolation,
Func< Exception, T, T >  exceptionMethod,
defaultValue = default 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
isolationDefault = ReadCommitted. Isolation level for the transaction.
exceptionMethodDefault = ExceptionRethrow. If an exception is thrown during "method", how will it be handled (besides being rolled back)
defaultValueDefault = Default(T). If an exception is thrown during "method", and it is not rethrowing the exception, this will instead be returned
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Run< T >() [5/6]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Run< T > ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse< T >>>  method,
IsolationLevel  isolation,
defaultValue 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
isolationDefault = ReadCommitted. Isolation level for the transaction.
defaultValueDefault = Default(T). If an exception is thrown during "method", and it is not rethrowing the exception, this will instead be returned
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

◆ Run< T >() [6/6]

static Task<T> Sphyrnidae.Common.Dal.Transaction< TC >.Run< T > ( ILogger  logger,
string  cnnStr,
Func< IDbTransaction< TC >, Task< TransactionResponse< T >>>  method,
defaultValue 
)
static

Wrapper for multiple Sql calls (Single database) within a transaction

Template Parameters
TReturn type of the complete transaction
Parameters
loggerThe logger for the transaction sequence
cnnStrThe connection string to use for all calls within the transaction
methodThe actual SQL calls
defaultValueDefault = Default(T). If an exception is thrown during "method", and it is not rethrowing the exception, this will instead be returned
Returns
The result from the SQL calls (method) - or possibly default(T) if there was an exception

The documentation for this class was generated from the following file: