C# Class Npgsql.NpgsqlConnection

Inheritance: System.Data.Common.DbConnection, ICloneable
显示文件 Open project: undeadlabs/Npgsql Class Usage Examples

Private Properties

Property Type Description
CheckConnectionClosed void
CheckConnectionOpen void
CheckNotDisposed void
CopyConnectionStringBuilder NpgsqlConnectionStringBuilder
DefaultCertificateSelectionCallback System.Security.Cryptography.X509Certificates.X509Certificate
DefaultCertificateValidationCallback bool
DefaultPrivateKeySelectionCallback System.Security.Cryptography.AsymmetricAlgorithm
DefaultProvideClientCertificatesCallback void
DefaultValidateRemoteCertificateCallback bool
EmergencyClose void
ICloneable Object
Init void
LoadConnectionStringBuilder void
LoadConnectionStringBuilder void
LogConnectionString void
OnNotice void
OnNotification void
PromotableLocalTransactionEnded void
ReallyClose void
RefreshConnectionString void

Public Methods

Method Description
BeginTransaction ( ) : NpgsqlTransaction

Begins a database transaction.

Currently there's no support for nested transactions.

BeginTransaction ( System.Data.IsolationLevel level ) : NpgsqlTransaction

Begins a database transaction with the specified isolation level.

Currently the IsolationLevel ReadCommitted and Serializable are supported by the PostgreSQL backend. There's no support for nested transactions.

ChangeDatabase ( String dbName ) : void

This method changes the current database by disconnecting from the actual database and connecting to the specified.

ClearAllPools ( ) : void

Clear all connection pools.

ClearPool ( ) : void

Clear connection pool.

Clone ( ) : NpgsqlConnection

Create a new connection based on this one.

Close ( ) : void

Releases the connection to the database. If the connection is pooled, it will be made available for re-use. If it is non-pooled, the actual connection will be shutdown.

CreateCommand ( ) : NpgsqlCommand

Creates and returns a NpgsqlCommand object associated with the NpgsqlConnection.

EnlistTransaction ( Transaction transaction ) : void

Enlist transation.

GetSchema ( ) : DataTable

Returns the supported collections

GetSchema ( string collectionName ) : DataTable

Returns the schema collection specified by the collection name.

GetSchema ( string collectionName, string restrictions ) : DataTable

Returns the schema collection specified by the collection name filtered by the restrictions.

NpgsqlConnection ( ) : System

Initializes a new instance of the NpgsqlConnection class.

NpgsqlConnection ( NpgsqlConnectionStringBuilder ConnectionString ) : System

Initializes a new instance of the NpgsqlConnection class and sets the ConnectionString.

NpgsqlConnection ( String ConnectionString ) : System

Initializes a new instance of the NpgsqlConnection class and sets the ConnectionString.

Open ( ) : void

Opens a database connection with the property settings specified by the ConnectionString.

Protected Methods

Method Description
BeginDbTransaction ( System.Data.IsolationLevel isolationLevel ) : DbTransaction

Begins a database transaction with the specified isolation level.

Currently the IsolationLevel ReadCommitted and Serializable are supported by the PostgreSQL backend. There's no support for nested transactions.

CreateDbCommand ( ) : DbCommand

Creates and returns a DbCommand object associated with the IDbConnection.

Dispose ( bool disposing ) : void

Releases all resources used by the NpgsqlConnection.

Private Methods

Method Description
CheckConnectionClosed ( ) : void
CheckConnectionOpen ( ) : void
CheckNotDisposed ( ) : void
CopyConnectionStringBuilder ( ) : NpgsqlConnectionStringBuilder

Returns a copy of the NpgsqlConnectionStringBuilder that contains the parsed connection string values.

DefaultCertificateSelectionCallback ( X509CertificateCollection clientCertificates, X509Certificate serverCertificate, string targetHost, X509CertificateCollection serverRequestedCertificates ) : X509Certificate

Default SSL CertificateSelectionCallback implementation.

DefaultCertificateValidationCallback ( X509Certificate certificate, int certificateErrors ) : bool

Default SSL CertificateValidationCallback implementation.

DefaultPrivateKeySelectionCallback ( X509Certificate certificate, string targetHost ) : AsymmetricAlgorithm

Default SSL PrivateKeySelectionCallback implementation.

DefaultProvideClientCertificatesCallback ( X509CertificateCollection certificates ) : void

Default SSL ProvideClientCertificatesCallback implementation.

DefaultValidateRemoteCertificateCallback ( X509Certificate cert, X509Chain chain, SslPolicyErrors errors ) : bool

Default SSL ValidateRemoteCertificateCallback implementation.

EmergencyClose ( ) : void
ICloneable ( ) : Object

Create a new connection based on this one.

Init ( ) : void
LoadConnectionStringBuilder ( NpgsqlConnectionStringBuilder connectionString ) : void

Sets the `settings` ConnectionStringBuilder based on the given `connectionString`

LoadConnectionStringBuilder ( string connectionString ) : void

Sets the `settings` ConnectionStringBuilder based on the given `connectionString`

LogConnectionString ( ) : void

Write each key/value pair in the connection string to the log.

OnNotice ( object O, Npgsql.NpgsqlNoticeEventArgs E ) : void
OnNotification ( object O, Npgsql.NpgsqlNotificationEventArgs E ) : void
PromotableLocalTransactionEnded ( ) : void

When a connection is closed within an enclosing TransactionScope and the transaction hasn't been promoted, we defer the actual closing until the scope ends.

ReallyClose ( ) : void
RefreshConnectionString ( ) : void

Refresh the cached _connectionString whenever the builder settings change

Method Details

BeginDbTransaction() protected method

Begins a database transaction with the specified isolation level.
Currently the IsolationLevel ReadCommitted and Serializable are supported by the PostgreSQL backend. There's no support for nested transactions.
protected BeginDbTransaction ( System.Data.IsolationLevel isolationLevel ) : DbTransaction
isolationLevel System.Data.IsolationLevel The isolation level under which the transaction should run.
return System.Data.Common.DbTransaction

BeginTransaction() public method

Begins a database transaction.
Currently there's no support for nested transactions.
public BeginTransaction ( ) : NpgsqlTransaction
return NpgsqlTransaction

BeginTransaction() public method

Begins a database transaction with the specified isolation level.
Currently the IsolationLevel ReadCommitted and Serializable are supported by the PostgreSQL backend. There's no support for nested transactions.
public BeginTransaction ( System.Data.IsolationLevel level ) : NpgsqlTransaction
level System.Data.IsolationLevel The isolation level under which the transaction should run.
return NpgsqlTransaction

ChangeDatabase() public method

This method changes the current database by disconnecting from the actual database and connecting to the specified.
public ChangeDatabase ( String dbName ) : void
dbName String The name of the database to use in place of the current database.
return void

ClearAllPools() public static method

Clear all connection pools.
public static ClearAllPools ( ) : void
return void

ClearPool() public method

Clear connection pool.
public ClearPool ( ) : void
return void

Clone() public method

Create a new connection based on this one.
public Clone ( ) : NpgsqlConnection
return NpgsqlConnection

Close() public method

Releases the connection to the database. If the connection is pooled, it will be made available for re-use. If it is non-pooled, the actual connection will be shutdown.
public Close ( ) : void
return void

CreateCommand() public method

Creates and returns a NpgsqlCommand object associated with the NpgsqlConnection.
public CreateCommand ( ) : NpgsqlCommand
return NpgsqlCommand

CreateDbCommand() protected method

Creates and returns a DbCommand object associated with the IDbConnection.
protected CreateDbCommand ( ) : DbCommand
return System.Data.Common.DbCommand

Dispose() protected method

Releases all resources used by the NpgsqlConnection.
protected Dispose ( bool disposing ) : void
disposing bool true when called from Dispose(); /// false when being called from the finalizer.
return void

EnlistTransaction() public method

Enlist transation.
public EnlistTransaction ( Transaction transaction ) : void
transaction System.Transactions.Transaction
return void

GetSchema() public method

Returns the supported collections
public GetSchema ( ) : DataTable
return System.Data.DataTable

GetSchema() public method

Returns the schema collection specified by the collection name.
public GetSchema ( string collectionName ) : DataTable
collectionName string The collection name.
return System.Data.DataTable

GetSchema() public method

Returns the schema collection specified by the collection name filtered by the restrictions.
public GetSchema ( string collectionName, string restrictions ) : DataTable
collectionName string The collection name.
restrictions string /// The restriction values to filter the results. A description of the restrictions is contained /// in the Restrictions collection. ///
return System.Data.DataTable

NpgsqlConnection() public method

Initializes a new instance of the NpgsqlConnection class.
public NpgsqlConnection ( ) : System
return System

NpgsqlConnection() public method

Initializes a new instance of the NpgsqlConnection class and sets the ConnectionString.
public NpgsqlConnection ( NpgsqlConnectionStringBuilder ConnectionString ) : System
ConnectionString NpgsqlConnectionStringBuilder The connection used to open the PostgreSQL database.
return System

NpgsqlConnection() public method

Initializes a new instance of the NpgsqlConnection class and sets the ConnectionString.
public NpgsqlConnection ( String ConnectionString ) : System
ConnectionString String The connection used to open the PostgreSQL database.
return System

Open() public method

Opens a database connection with the property settings specified by the ConnectionString.
public Open ( ) : void
return void