public SessionState(
IConfiguration configuration,
IDbConnection connection,
IDbTransaction transaction = null,
bool disposeConnection = true,
bool commitAndDisposeTransaction = false,
bool isTransactionLess = false) {
if (connection == null) {
throw new ArgumentNullException("connection");
}
if (transaction != null && isTransactionLess) {
throw new InvalidOperationException("Unable to start a transaction-less session as transaction is not null");
}
if (isTransactionLess && commitAndDisposeTransaction) {
throw new InvalidOperationException(
"As this session is transaction-less it will not be possible to commit and dispose of the transaction");
}
this.configuration = configuration;
this.connection = connection;
this.transaction = transaction;
this.shouldDisposeConnection = disposeConnection;
this.shouldCommitAndDisposeTransaction = commitAndDisposeTransaction;
this.isTransactionLess = isTransactionLess;
}