Example #1
0
        private SqlInternalConnectionSmi GetContextConnection(SqlConnectionString options, object providerInfo)
        {
            SmiContext smiContext = SmiContextFactory.Instance.GetCurrentContext();

            SqlInternalConnectionSmi result = (SqlInternalConnectionSmi)smiContext.GetContextValue((int)SmiContextFactory.ContextKey.Connection);

            // context connections are automatically re-useable if they exist unless they've been doomed.
            if (null == result || result.IsConnectionDoomed)
            {
                if (null != result)
                {
                    result.Dispose();   // A doomed connection is a messy thing.  Dispose of it promptly in nearest receptacle.
                }

                result = new SqlInternalConnectionSmi(options, smiContext);
                smiContext.SetContextValue((int)SmiContextFactory.ContextKey.Connection, result);
            }

            result.Activate();

            return(result);
        }
Example #2
0
 internal EventSink(SqlInternalConnectionSmi connection)
 {
     Debug.Assert(null != connection, "null connection?");
     _connection = connection;
 }