OpenPetra
Free Administration Software for Non-Profits
|
Allows access to PostgreSQL databases using the 'Npgsql' .NET Data Provider. More...
Public Member Functions | |
DbConnection | GetConnection (String AServer, String APort, String ADatabaseName, String AUsername, ref String APassword, ref String AConnectionString, StateChangeEventHandler AStateChangeEventHandler) |
Creates a PostgreSQL connection using the 'Npgsql' .NET Data Provider. This works on Windows and on Linux. More... | |
void | InitConnection (DbConnection AConnection) |
Initialises the connection after it was opened. Doesn't do anything with PostgreSQL! More... | |
bool | LogException (Exception AException, ref string AErrorMessage) |
Formats an error message if the Exception is of Type 'PostgresException'. More... | |
String | FormatQueryRDBMSSpecific (String ASqlQuery) |
Formats a SQL query so that it works for PostgreSQL. See also the comments for TDataBase.FormatQueryRDBMSSpecific. More... | |
DbParameter[] | ConvertOdbcParameters (DbParameter[] AParameterArray, ref string ASqlStatement) |
Converts an Array of DbParameter (eg. OdbcParameter) to an Array of NpgsqlParameter. If the Parameters don't have a name yet, they are given one because PostgreSQL needs named Parameters. More... | |
DbCommand | NewCommand (ref string ACommandText, DbConnection AConnection, DbParameter[] AParametersArray, TDBTransaction ATransaction) |
Creates a DbCommand object. This formats the sql query for PostgreSQL, and transforms the parameters. More... | |
DbDataAdapter | NewAdapter () |
Creates a DbDataAdapter for PostgreSQL. More... | |
void | FillAdapter (DbDataAdapter TheAdapter, ref DataSet AFillDataSet, Int32 AStartRecord, Int32 AMaxRecords, string ADataTableName) |
Fills a DbDataAdapter that was created with the NewAdapter Method. More... | |
void | FillAdapter (DbDataAdapter TheAdapter, ref DataTable AFillDataTable, Int32 AStartRecord, Int32 AMaxRecords) |
Fills a DbDataAdapter that was created with the NewAdapter Method. More... | |
bool | AdjustIsolationLevel (ref IsolationLevel AIsolationLevel) |
Some RDMBS's have some problems with certain Isolation Levels - not so PostgreSQL. More... | |
System.Int64 | GetNextSequenceValue (String ASequenceName, TDBTransaction ATransaction, TDataBase ADatabase) |
Returns the next Sequence Value for the given Sequence from the DB. - IMPORTANT: This increasing of the Value of the Sequence PERSISTS in the PostgreSQL implmentation even if the DB Transction gets rolled back!!! --> See https://wiki.openpetra.org/index.php/PostgreSQL:_Sequences_Not_Tied_to_DB_Transactions More... | |
System.Int64 | GetCurrentSequenceValue (String ASequenceName, TDBTransaction ATransaction, TDataBase ADatabase) |
Returns the current sequence value for the given Sequence from the DB. More... | |
void | RestartSequence (String ASequenceName, TDBTransaction ATransaction, TDataBase ADatabase, Int64 ARestartValue) |
Restart a sequence with the given value. More... | |
void | UpdateDatabase (TFileVersionInfo ADBVersion, TFileVersionInfo AExeVersion, string AHostOrFile, string ADatabasePort, string ADatabaseName, string AUsername, string APassword) |
Updating of a Postgresql database has not been implemented yet, need to do this still manually. More... | |
void | ClearConnectionPool (DbConnection ADBConnection) |
Clears (empties) the Connection Pool that the Npgsql driver for PostgreSQL provides for all connections that were created using the Connection String that is associated with ADBConnection . More... | |
Static Public Member Functions | |
static void | ClearAllConnectionPools () |
Clears (empties) all the Connection Pools that the Npgsql driver for PostgreSQL provides (irrespecive of the Connection String that is associated with any connection). More... | |
Allows access to PostgreSQL databases using the 'Npgsql' .NET Data Provider.
|
inline |
Some RDMBS's have some problems with certain Isolation Levels - not so PostgreSQL.
AIsolationLevel | Isolation Level. |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inlinestatic |
Clears (empties) all the Connection Pools that the Npgsql driver for PostgreSQL provides (irrespecive of the Connection String that is associated with any connection).
THERE IS NORMALLY NO NEED TO EXECUTE THIS METHOD - IN FACT THIS METHOD SHOULD NOT GET CALLED as it will have a negative performance impact when subsequent DB Connections are opened! Use this Method only for 'unit-testing' DB Connection-related issues (such as that DB Connections are really closed when they ought to be).
|
inline |
Clears (empties) the Connection Pool that the Npgsql driver for PostgreSQL provides for all connections that were created using the Connection String that is associated with ADBConnection .
THERE IS NORMALLY NO NEED TO EXECUTE THIS METHOD - IN FACT THIS METHOD SHOULD NOT GET CALLED as it will have a negative performance impact when subsequent DB Connections are opened! Use this Method only for 'unit-testing' DB Connection-related issues (such as that DB Connections are really closed when they ought to be).
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Converts an Array of DbParameter (eg. OdbcParameter) to an Array of NpgsqlParameter. If the Parameters don't have a name yet, they are given one because PostgreSQL needs named Parameters.
Furthermore, the parameter placeholders '?' in the the passed in ASqlStatement are replaced with PostgreSQL ':paramX' placeholders (where 'paramX' is the name of the Parameter).
AParameterArray | Array of DbParameter that is to be converted. |
ASqlStatement | SQL Statement. It will be converted! |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Fills a DbDataAdapter that was created with the NewAdapter Method.
TheAdapter | |
AFillDataSet | |
AStartRecord | |
AMaxRecords | |
ADataTableName |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Fills a DbDataAdapter that was created with the NewAdapter Method.
Overload of FillAdapter, just for one table.
TheAdapter | |
AFillDataTable | |
AStartRecord | |
AMaxRecords |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Formats a SQL query so that it works for PostgreSQL. See also the comments for TDataBase.FormatQueryRDBMSSpecific.
ASqlQuery | SQL Query. |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Creates a PostgreSQL connection using the 'Npgsql' .NET Data Provider. This works on Windows and on Linux.
AServer | Database Server. |
APort | Port that the DB server is running on. |
ADatabaseName | Name of the database that we want to connect to. |
AUsername | Username for opening the PostgreSQL connection. |
APassword | Password for opening the PostgreSQL connection. |
AConnectionString | Connection string; if it is not empty, it will overrule the previous parameters. |
AStateChangeEventHandler | Event Handler for connection state changes (NOTE: This doesn't work yet with the Npgsql driver - see code comments in this Methods' source code)! |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Returns the current sequence value for the given Sequence from the DB.
ASequenceName | Name of the Sequence. |
ATransaction | An instantiated Transaction in which the Query to the DB will be enlisted. |
ADatabase | Database object that can be used for querying. |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Returns the next Sequence Value for the given Sequence from the DB. - IMPORTANT: This increasing of the Value of the Sequence PERSISTS in the PostgreSQL implmentation even if the DB Transction gets rolled back!!! --> See https://wiki.openpetra.org/index.php/PostgreSQL:_Sequences_Not_Tied_to_DB_Transactions
ASequenceName | Name of the Sequence. |
ATransaction | An instantiated Transaction in which the Query to the DB will be enlisted. |
ADatabase | Database object that can be used for querying. |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Initialises the connection after it was opened. Doesn't do anything with PostgreSQL!
AConnection | DB Connection. |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Formats an error message if the Exception is of Type 'PostgresException'.
AException | |
AErrorMessage |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Creates a DbDataAdapter for PostgreSQL.
Important: Since an object that derives from DbDataAdapter is returned you ought to call .Dispose() on the returned object to release its resouces! (DbDataAdapter inherits from DataAdapter which itself inherits from Component, which implements IDisposable!)
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Creates a DbCommand object. This formats the sql query for PostgreSQL, and transforms the parameters.
ACommandText | |
AConnection | |
AParametersArray | |
ATransaction |
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Restart a sequence with the given value.
Implements Ict.Common.DB.IDataBaseRDBMS.
|
inline |
Updating of a Postgresql database has not been implemented yet, need to do this still manually.