Aspectacular.SqlCmdExecutionPlanAspect.OnConnectionOpened C# (CSharp) Method

OnConnectionOpened() private method

private OnConnectionOpened ( ) : void
return void
        private void OnConnectionOpened()
        {
            string outputFormat = this.TrueText_FalseXml ? "text" : "xml";

            SqlCommand showplanCmd = new SqlCommand("set showplan_{0} on".SmartFormat(outputFormat), this.command.Connection);
            showplanCmd.ExecuteNonQuery();

            string executionPlan = null;
            using(SqlDataReader showplan_results = this.command.ExecuteReader())
            {
                if(showplan_results.Read())
                    executionPlan = showplan_results[0].ToString();
            }

            if(executionPlan != null)
                this.ProcessExecutionPlan(executionPlan);

            SqlCommand showplan_off_cmd = new SqlCommand("set showplan_{0} off".SmartFormat(outputFormat), this.command.Connection);
            showplan_off_cmd.ExecuteNonQuery();
        }