PeanutButter
Loading...
Searching...
No Matches
PeanutButter.TempDb.TempDB< TDatabaseConnection > Class Template Referenceabstract
Inheritance diagram for PeanutButter.TempDb.TempDB< TDatabaseConnection >:
PeanutButter.TempDb.ITempDB PeanutButter.TempDb.LocalDb.TempDBLocalDb PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T > PeanutButter.TempDb.SqlCe.TempDBSqlCe PeanutButter.TempDb.Sqlite.TempDBSqlite PeanutButter.TempDb.MySql.Connector.TempDBMySql PeanutButter.TempDb.MySql.Data.TempDBMySql

Public Member Functions

 TempDB (params string[] creationScripts)
 TempDB (Action< object > beforeInit, params string[] creationScripts)
string DumpSchema ()
 (Where supported) dumps the current schema of the running database Currently only supported on mysql, when mysqldump is available
void SetupAutoDispose (TimeSpan absoluteTimeout)
 Set up automatic disposal of this TempDb instance (may only be done once per instance)
void SetupAutoDispose (TimeSpan? absoluteTimeout, TimeSpan? inactivityTimeout)
 Set up automatic disposal of this TempDb instance (may only be done once per instance)
int TryFetchCurrentConnectionCount ()
DbConnection CreateConnection ()
virtual DbConnection OpenConnection ()
 Opens a new connection to the TempDb instance with the connection string automatically set based on the current running parameters.
void RunScripts (IEnumerable< string > scripts)
virtual void Dispose ()
void DisposeManagedConnections ()
 Close and dispose of any connections which were created by OpenConnection()

Protected Member Functions

virtual void Init (string[] creationScripts)
int FetchCurrentConnectionCount ()
void CheckForInactivity (object _)
void Log (string message, params object[] parameters)
 Provides a convenience logging mechanism which outputs via the established LogAction.
virtual string GenerateConnectionString ()
void CreateDatabase ()
virtual void DeleteTemporaryDataArtifacts ()

Properties

uint DefaultTimeout = 30 [get, set]
TempDbDisposedEventHandler Disposed [get, set]
 Fired when the instance is disposed. Useful if you've set up automatic disposal and would like to act on that.
bool KeepTemporaryDatabaseArtifactsForDiagnostics [get, set]
string DatabasePath [get, set]
 Path to where the temporary database resides. May be a file for single-file databases or a folder.
string ConnectionString [get]
Action< string > LogAction [get, set]
static string[] UndeletedArtifacts [get]

Member Function Documentation

◆ CreateConnection()

DbConnection PeanutButter.TempDb.TempDB< TDatabaseConnection >.CreateConnection ( )

◆ Dispose()

virtual void PeanutButter.TempDb.TempDB< TDatabaseConnection >.Dispose ( )
virtual

◆ DisposeManagedConnections()

void PeanutButter.TempDb.TempDB< TDatabaseConnection >.DisposeManagedConnections ( )

Close and dispose of any connections which were created by OpenConnection()

Implements PeanutButter.TempDb.ITempDB.

◆ DumpSchema()

string PeanutButter.TempDb.TempDB< TDatabaseConnection >.DumpSchema ( )
abstract

(Where supported) dumps the current schema of the running database Currently only supported on mysql, when mysqldump is available

Returns

Implements PeanutButter.TempDb.ITempDB.

◆ GenerateConnectionString()

virtual string PeanutButter.TempDb.TempDB< TDatabaseConnection >.GenerateConnectionString ( )
protectedvirtual

◆ Log()

void PeanutButter.TempDb.TempDB< TDatabaseConnection >.Log ( string message,
params object[] parameters )
protected

Provides a convenience logging mechanism which outputs via the established LogAction.

Parameters
message
parameters

◆ OpenConnection()

virtual DbConnection PeanutButter.TempDb.TempDB< TDatabaseConnection >.OpenConnection ( )
virtual

Opens a new connection to the TempDb instance with the connection string automatically set based on the current running parameters.

Returns

Implements PeanutButter.TempDb.ITempDB.

Reimplemented in PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.

◆ SetupAutoDispose() [1/2]

void PeanutButter.TempDb.TempDB< TDatabaseConnection >.SetupAutoDispose ( TimeSpan absoluteTimeout)

Set up automatic disposal of this TempDb instance (may only be done once per instance)

Parameters
absoluteTimeoutAbsolute timeout after which this instance is automatically disposed irrespective of ongoing connections
Exceptions
InvalidOperationExceptionWill be thrown if this method is invoked more than once per instance

Implements PeanutButter.TempDb.ITempDB.

◆ SetupAutoDispose() [2/2]

void PeanutButter.TempDb.TempDB< TDatabaseConnection >.SetupAutoDispose ( TimeSpan? absoluteTimeout,
TimeSpan? inactivityTimeout )

Set up automatic disposal of this TempDb instance (may only be done once per instance)

Parameters
inactivityTimeoutInactivity timeout (only supported on mysql so far)
absoluteTimeoutAbsolute timeout after which this instance is automatically disposed irrespective of ongoing connections
Exceptions
InvalidOperationExceptionWill be thrown if this method is invoked more than once per instance

Implements PeanutButter.TempDb.ITempDB.

Property Documentation

◆ ConnectionString

string PeanutButter.TempDb.TempDB< TDatabaseConnection >.ConnectionString
get

◆ DatabasePath

string PeanutButter.TempDb.TempDB< TDatabaseConnection >.DatabasePath
getset

Path to where the temporary database resides. May be a file for single-file databases or a folder.

Implements PeanutButter.TempDb.ITempDB.

◆ Disposed

TempDbDisposedEventHandler PeanutButter.TempDb.TempDB< TDatabaseConnection >.Disposed
getset

Fired when the instance is disposed. Useful if you've set up automatic disposal and would like to act on that.

Implements PeanutButter.TempDb.ITempDB.


The documentation for this class was generated from the following file:
  • source/TempDb/PeanutButter.TempDb/TempDB.cs