示例#1
0
        protected void DropTableOrView(TableOrView tableOrView)
        {
            // TODO: move this to schema eventually
            string sql = @"
            IF (OBJECT_ID('[{0}].[{1}].[{2}]') IS NOT NULL)
            BEGIN
            DROP {3} [{0}].[{1}].[{2}]
            END";

            sql = String.Format(
                sql,
                !String.IsNullOrWhiteSpace(tableOrView.DatabaseName) ? tableOrView.DatabaseName : tableOrView.Dataset.DatabaseName,
                tableOrView.SchemaName,
                tableOrView.ObjectName,
                tableOrView.GetType().Name);

            ExecuteCommandNonQuery(sql, tableOrView.Dataset.ConnectionString);
        }