8.5. Implementing the Connection Class

To implement the Connection class, you start by implementing IDbConnection, shown in Listing 8-2. Note that IDbConnection inherits from IDisposable.

Listing 8-2. The IDbConnection interface
public interface IDbConnection : IDisposable
{
  IDbTransaction BeginTransaction(IsolationLevel iso);
  IDbTransaction BeginTransaction();
  bool ChangeDatabase(string newdb);
  void Close();
  IDbCommand CreateCommand();
  void Open();

// properties
 string ConnectionString {get; set;}
 int ConnectionTimeout {get; set;}
 string Database {get; set;}
 ConnectionState State {get;}
}

8.5.1. Specification

IDbConnection has six public methods. The most obvious are Open and Close. Because the .NET runtime does not include the concept of ...

Get Essential ADO.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.