예제 #1
0
        public async Task DropStoredProceduresAsync()
        {
            string sqlQueryDropFirstStoredProcedure =
                _sqlQueryBuilder.BuildDropStoredProcedureQuery(StoredProcedureTesterTestsConsts
                                                               .TestUnoptimisedStoredProcedureName);
            string sqlQueryDropSecondStoredProcedure =
                _sqlQueryBuilder.BuildDropStoredProcedureQuery(StoredProcedureTesterTestsConsts
                                                               .TestOptimisedStoredProcedureName);

            string dropSchemaSql = _sqlQueryBuilder.BuildDropSchemaQuery();

            using (SqlConnection connection = new SqlConnection(StoredProcedureTesterTestsConsts.ConnectionString))
            {
                SqlCommand dropUnoptimisedStoredProcedure = new SqlCommand(sqlQueryDropFirstStoredProcedure, connection);
                SqlCommand dropOptimisedStoredProcedure   = new SqlCommand(sqlQueryDropSecondStoredProcedure, connection);
                SqlCommand dropSchema = new SqlCommand(dropSchemaSql, connection);
                await connection.OpenAsync();

                await dropUnoptimisedStoredProcedure.ExecuteNonQueryAsync();

                await dropOptimisedStoredProcedure.ExecuteNonQueryAsync();

                await dropSchema.ExecuteNonQueryAsync();
            }
        }