ConnectionContext Class

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

Inheritance Hierarchy

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

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

Syntax

'Declaration
Public Class ConnectionContext _
    Implements IDisposable
public class ConnectionContext : IDisposable
public ref class ConnectionContext : IDisposable
type ConnectionContext =  
    class
        interface IDisposable
    end
public class ConnectionContext implements IDisposable

The ConnectionContext type exposes the following members.

Constructors

  Name Description
Public method ConnectionContext Initializes a new instance of the ConnectionContext class.

Top

Properties

  Name Description
Public property CommandTimeout Gets or sets the time (in seconds) that elapses before the command that executes the batch statement times out.
Public property Connection Gets or sets the database connection.
Public property Provider Gets or sets a provider that is associated with the connection.
Public property Transaction Gets or sets the transactions to use when executing the Transact-SQL statements.

Top

Methods

  Name Description
Public method Dispose() Releases resources used by a connection.
Protected method Dispose(Boolean) Releases the unmanaged resources used by the connection and, optionally, releases the managed resources.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

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

Reference

Microsoft.Data.Schema.UnitTesting Namespace

ConnectionContextElement

Execute