ConnectionContext Class

 

Represents the context for the database connection that is associated with the database unit test.

Namespace:   Microsoft.Data.Tools.Schema.Sql.UnitTesting
Assembly:  Microsoft.Data.Tools.Schema.Sql.UnitTesting (in Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll)

Inheritance Hierarchy

System.Object
  Microsoft.Data.Tools.Schema.Sql.UnitTesting.ConnectionContext

Syntax

public class ConnectionContext : IDisposable
public ref class ConnectionContext : IDisposable
type ConnectionContext = 
    class
        interface IDisposable
    end
Public Class ConnectionContext
    Implements IDisposable

Constructors

Name Description
System_CAPS_pubmethod ConnectionContext()

Initializes a new instance of the ConnectionContext class.

Properties

Name Description
System_CAPS_pubproperty CommandTimeout

Gets or sets the time (in seconds) that elapses before the command that executes the batch statement times out.

System_CAPS_pubproperty Connection

Gets or sets the database connection.

System_CAPS_pubproperty Provider

Gets or sets a provider that is associated with the connection.

System_CAPS_pubproperty Transaction

Gets or sets the transactions to use when executing the Transact-SQL statements.

Methods

Name Description
System_CAPS_pubmethod Dispose()

Releases resources used by a connection.

System_CAPS_protmethod Dispose(Boolean)

Releases the unmanaged resources used by the connection and, optionally, releases the managed resources.

System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

This class provides connection and execution information to the Execute method when the Transact-SQL is executed. ConnectionContext uses types in the System.Data.Common namespace, regardless of database type.

Use this type to store the state of an open connection for later use. For example, you can save the impersonation context from an open connection if you want to use the same connection string and Windows authentication with two sets of Windows credentials. For more information, see Impersonate. You must release the context in the Dispose method.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

T:Microsoft.Data.Schema.UnitTesting.Configuration.ConnectionContextElement
Execute
Microsoft.Data.Tools.Schema.Sql.UnitTesting Namespace

Return to top