RelationalConnection RelationalConnection Class

Definition

Represents a connection with a relational database.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public abstract class RelationalConnection : IRelationalConnection, IRelationalTransactionManager, IDbContextTransactionManager, IDisposable
Public MustInherit Class RelationalConnection
    Implements IRelationalConnection, IRelationalTransactionManager, IDbContextTransactionManager, IDisposable
Inheritance
System.ObjectSystem.Object
RelationalConnectionRelationalConnection
Implements

Constructors

RelationalConnection(IDbContextOptions, ILogger) RelationalConnection(IDbContextOptions, ILogger)

Initializes a new instance of the IRelationalConnection class.

protected RelationalConnection(IDbContextOptions options, ILogger logger)
Protected Sub New(options As IDbContextOptions, logger As ILogger)
Parameters
options
IDbContextOptions IDbContextOptions

The options for the context that this connection will be used with.

logger
ILogger ILogger

The logger to write to.

Properties

ActiveCursor ActiveCursor

Gets or sets the active cursor.

public virtual IValueBufferCursor ActiveCursor { get; set; }
Public Overridable Property ActiveCursor As IValueBufferCursor

CommandTimeout CommandTimeout

Gets the timeout for executing a command against the database.

public virtual int ? CommandTimeout { get; set; }
Public Overridable Property CommandTimeout As Integer?
Value
System.Nullable<System.Int32> System.Nullable(Of System.Int32)

ConnectionString ConnectionString

Gets the connection string for the database.

public virtual string ConnectionString { get; }
Public Overridable ReadOnly Property ConnectionString As String
Value
System.String System.String

CurrentTransaction CurrentTransaction

Gets the current transaction.

public virtual IDbContextTransaction CurrentTransaction { get; protected set; }
Public Overridable Property CurrentTransaction As IDbContextTransaction

DbConnection DbConnection

Gets the underlying System.Data.Common.DbConnection used to connect to the database.

public virtual DbConnection DbConnection { get; }
Public Overridable ReadOnly Property DbConnection As DbConnection
Value
System.Data.Common.DbConnection System.Data.Common.DbConnection

IsMultipleActiveResultSetsEnabled IsMultipleActiveResultSetsEnabled

Gets a value indicating whether the multiple active result sets feature is enabled.

public virtual bool IsMultipleActiveResultSetsEnabled { get; }
Public Overridable ReadOnly Property IsMultipleActiveResultSetsEnabled As Boolean
Value
System.Boolean System.Boolean

Logger Logger

Gets the logger to write to.

protected virtual ILogger Logger { get; }
Protected Overridable ReadOnly Property Logger As ILogger
Value
ILogger ILogger

Methods

BeginTransaction() BeginTransaction()

Begins a new transaction.

public virtual IDbContextTransaction BeginTransaction()
Public Overridable Function BeginTransaction As IDbContextTransaction
Returns

The newly created transaction.

BeginTransaction(IsolationLevel) BeginTransaction(IsolationLevel)

Begins a new transaction.

public virtual IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel)
Public Overridable Function BeginTransaction(isolationLevel As IsolationLevel) As IDbContextTransaction
Parameters
isolationLevel
System.Data.IsolationLevel System.Data.IsolationLevel

The isolation level to use for the transaction.

Returns

The newly created transaction.

BeginTransactionAsync(CancellationToken) BeginTransactionAsync(CancellationToken)

Asynchronously begins a new transaction.

public virtual Task<IDbContextTransaction> BeginTransactionAsync(CancellationToken cancellationToken = null)
Public Overridable Function BeginTransactionAsync(cancellationToken As CancellationToken = Nothing) As Task(Of IDbContextTransaction)
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<IDbContextTransaction> System.Threading.Tasks.Task(Of IDbContextTransaction)

A task that represents the asynchronous operation. The task result contains the newly created transaction.

BeginTransactionAsync(IsolationLevel, CancellationToken) BeginTransactionAsync(IsolationLevel, CancellationToken)

Asynchronously begins a new transaction.

public virtual Task<IDbContextTransaction> BeginTransactionAsync(IsolationLevel isolationLevel, CancellationToken cancellationToken = null)
Public Overridable Function BeginTransactionAsync(isolationLevel As IsolationLevel, cancellationToken As CancellationToken = Nothing) As Task(Of IDbContextTransaction)
Parameters
isolationLevel
System.Data.IsolationLevel System.Data.IsolationLevel

The isolation level to use for the transaction.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<IDbContextTransaction> System.Threading.Tasks.Task(Of IDbContextTransaction)

A task that represents the asynchronous operation. The task result contains the newly created transaction.

Close() Close()

Closes the connection to the database.

public virtual void Close()
Public Overridable Sub Close

CommitTransaction() CommitTransaction()

Commits all changes made to the database in the current transaction.

public virtual void CommitTransaction()
Public Overridable Sub CommitTransaction

CreateDbConnection() CreateDbConnection()

Creates a DbConnection to the database.

protected abstract DbConnection CreateDbConnection()
Protected MustOverride Function CreateDbConnection As DbConnection
Returns
System.Data.Common.DbConnection System.Data.Common.DbConnection

The connection.

Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public virtual void Dispose()
Public Overridable Sub Dispose

Equals(Object) Equals(Object)

Inherited from System.Object

Equals(Object, Object) Equals(Object, Object)

Inherited from System.Object

GetHashCode() GetHashCode()

Inherited from System.Object

GetType() GetType()

Inherited from System.Object

MemberwiseClone() MemberwiseClone()

Inherited from System.Object

Open() Open()

Opens the connection to the database.

public virtual void Open()
Public Overridable Sub Open

OpenAsync(CancellationToken) OpenAsync(CancellationToken)

Asynchronously opens the connection to the database.

public virtual Task OpenAsync(CancellationToken cancellationToken = null)
Public Overridable Function OpenAsync(cancellationToken As CancellationToken = Nothing) As Task
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

ReferenceEquals(Object, Object) ReferenceEquals(Object, Object)

Inherited from System.Object

RollbackTransaction() RollbackTransaction()

Discards all changes made to the database in the current transaction.

public virtual void RollbackTransaction()
Public Overridable Sub RollbackTransaction

ToString() ToString()

Inherited from System.Object

UseTransaction(DbTransaction) UseTransaction(DbTransaction)

Specifies an existing System.Data.Common.DbTransaction to be used for database operations.

public virtual IDbContextTransaction UseTransaction(DbTransaction transaction)
Public Overridable Function UseTransaction(transaction As DbTransaction) As IDbContextTransaction
Parameters
transaction
System.Data.Common.DbTransaction System.Data.Common.DbTransaction

The transaction to be used.

Returns