コード例 #1
0
        /// <summary>
        /// Remove any functions and tables that are present in the database. Note that this should only be called when
        /// connecting to the temporary database
        /// </summary>
        public void CleanDatabase()
        {
            if (!_tempDatabaseUsed)
            {
                throw new Exception("CleanDatabase() was called on something other than the temporary database.");
            }

            var schema = GetDatabaseSchema();

            if (schema.Functions.Count > 0)
            {
                _adminClient.ExecuteControlCommand(
                    CslCommandGenerator.GenerateFunctionsDropCommand(
                        schema.Functions.Select(f => f.Value.Name), true));
            }

            if (schema.Tables.Count > 0)
            {
                _adminClient.ExecuteControlCommand(
                    CslCommandGenerator.GenerateTablesDropCommand(
                        schema.Tables.Select(f => f.Value.Name), true));
            }
        }