RelationalConnection RelationalConnection Class

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.

Syntax

Declaration

public abstract class RelationalConnection : IRelationalConnection, IRelationalTransactionManager, IDbContextTransactionManager, IDisposablePublic MustInherit Class RelationalConnection
    Implements IRelationalConnection, IRelationalTransactionManager, IDbContextTransactionManager, IDisposable

Inheritance Hierarchy

  • System.Object
    System.Object
  • RelationalConnection
    RelationalConnection

Inherited Members

ToString(),
ToString(),
Equals(Object),
Equals(Object),
Equals(Object, Object),
Equals(Object, Object),
ReferenceEquals(Object, Object),
ReferenceEquals(Object, Object),
GetHashCode(),
GetHashCode(),
GetType(),
GetType(),
MemberwiseClone()
MemberwiseClone()

Constructors summary

Initializes a new instance of the IRelationalConnection class.

Properties summary

Gets or sets the active cursor.

Gets the timeout for executing a command against the database.

Gets the connection string for the database.

Gets the current transaction.

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

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

Gets the logger to write to.

Methods summary

Begins a new transaction.

Begins a new transaction.

Asynchronously begins a new transaction.

Asynchronously begins a new transaction.

Closes the connection to the database.

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

Creates a DbConnection to the database.

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

Opens the connection to the database.

Asynchronously opens the connection to the database.

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

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

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

Properties

  • ActiveCursor
    ActiveCursor

    Gets or sets the active cursor.

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

    Property Value

  • CommandTimeout
    CommandTimeout

    Gets the timeout for executing a command against the database.

    public virtual int ? CommandTimeout { get; set; }Public Overridable Property CommandTimeout As Integer?

    Property Value

    • System.Nullable<T><System.Int32>
      System.Nullable<T>(Of System.Int32)
  • ConnectionString
    ConnectionString

    Gets the connection string for the database.

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

    Property Value

    • System.String
      System.String
  • CurrentTransaction
    CurrentTransaction

    Gets the current transaction.

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

    Property Value

  • 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

    Property 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

    Property 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

    Property Value

    • ILogger
      ILogger

Methods

  • BeginTransaction()
    BeginTransaction()

    Begins a new transaction.

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

    Returns

  • 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

  • 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<TResult><IDbContextTransaction>
      System.Threading.Tasks.Task<TResult>(Of IDbContextTransaction)

      A task that represents the asynchronous operation. The task result contains 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<TResult><IDbContextTransaction>
      System.Threading.Tasks.Task<TResult>(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
  • 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.

  • RollbackTransaction()
    RollbackTransaction()

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

    public virtual void RollbackTransaction()Public Overridable Sub RollbackTransaction
  • 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

Details

Assembly

Microsoft.EntityFrameworkCore.Relational.dll