public void Dispose()
        {
            switch (_operation)
            {
            case CommandOperation:
                if (_exception != null)
                {
                    _diagnostics.WriteCommandError(_operationId, (SqlCommand)_context1, (SqlTransaction)_context2, _exception, _operationName);
                }
                else
                {
                    _diagnostics.WriteCommandAfter(_operationId, (SqlCommand)_context1, (SqlTransaction)_context2, _operationName);
                }
                break;

            case ConnectionOpenOperation:
                if (_exception != null)
                {
                    _diagnostics.WriteConnectionOpenError(_operationId, (SqlConnection)_context1, _exception, _operationName);
                }
                else
                {
                    _diagnostics.WriteConnectionOpenAfter(_operationId, (SqlConnection)_context1, _operationName);
                }
                break;

                // ConnectionCloseOperation is not implemented because it is conditionally emitted and that requires manual calls to the write apis
            }
        }