C# Class Piranha.Data.Database

Helper class used to create an open and ready to use database connection using the DbProviderFactory and the connectionString section in the application settings.
Mostra file Open project: PiranhaCMS/Piranha

Public Properties

Property Type Description
CurrentVersion int

Public Methods

Method Description
CreateCommand ( IDbConnection conn, IDbTransaction tx, string sql, object args = null ) : IDbCommand

Creates a command on the given connection and sql statement and fills it with the given parameters.

Login ( string login, string password ) : bool

Logs in the given user when no HttpContext is available.

LoginSys ( ) : void

Logs in the default sys user.

Logout ( ) : void

Logs out the current user.

OpenConnection ( string name = "piranha" ) : IDbConnection

Gets the database connection from the current config.

OpenTransaction ( string name = "piranha" ) : IDbTransaction

Opens a connection and creates a transaction on it.

Private Methods

Method Description
GetConnection ( string name ) : IDbConnection

Gets a connection from the current provider factory.

GetFactory ( string name ) : System.Data.Common.DbProviderFactory

Gets the current provider factory specified in the connection string section.

Method Details

CreateCommand() public static method

Creates a command on the given connection and sql statement and fills it with the given parameters.
public static CreateCommand ( IDbConnection conn, IDbTransaction tx, string sql, object args = null ) : IDbCommand
conn IDbConnection The connection
tx IDbTransaction
sql string The sql statement
args object The parameters
return IDbCommand

Login() public static method

Logs in the given user when no HttpContext is available.
public static Login ( string login, string password ) : bool
login string Username
password string Password
return bool

LoginSys() public static method

Logs in the default sys user.
public static LoginSys ( ) : void
return void

Logout() public static method

Logs out the current user.
public static Logout ( ) : void
return void

OpenConnection() public static method

Gets the database connection from the current config.
public static OpenConnection ( string name = "piranha" ) : IDbConnection
name string Optional name of the connection string to use
return IDbConnection

OpenTransaction() public static method

Opens a connection and creates a transaction on it.
public static OpenTransaction ( string name = "piranha" ) : IDbTransaction
name string Optional name of the connection string to use
return IDbTransaction

Property Details

CurrentVersion public_oe static_oe property

Gets the current database version.
public static int CurrentVersion
return int