Databases Reference
In-Depth Information
C#
public interface IDbConnection : IDisposable, IExtension
{
IDbTransaction BeginTransaction();
IDbCommand CreateCommand();
void Open();
void Close();
string ConnectionString { get; set; }
int ConnectionTimeout { get; }
}
VB.NET
Public Interface IDbConnection
Inherits IDisposable, IExtension
Function BeginTransaction() As IDbTransaction
Function CreateCommand() As IDbCommand
Sub Open()
Sub Close()
Property ConnectionString() As String
Property ConnectionTimeout() As Integer
End Interface
BeginTransaction Function
The BeginTransaction function is primarily responsible for initiating a new transaction and returning
a reference to a valid, implementation-specific transaction object. The file system, which is our data
store, does not support transactions, but this method is required by the interface. You need to ensure that
the developer who will use your object in code is aware of that fact. This is done by throwing a
NotSupportedException.
C#
public IDbTransaction BeginTransaction()
{ //example doesn't support transactions
throw new NotSupportedException(“Transactions not supported”);
}
VB.NET
Public Function BeginTransaction() As IDbTransaction _
Implements IDbConnection.BeginTransaction
'example doesn't support transactions
Throw New NotSupportedException(“Transactions not supported”)
End Function
CreateCommand Function
The CreateCommand function is responsible for creating and returning a reference to a valid implemen-
tation-specific Command object. The method uses an overloaded constructor of your custom Command
object in order to pass that object a reference to the current connection.
Search WWH ::




Custom Search