Ejemplo n.º 1
0
        /// <inheritdoc/>
        public override string Translate(SqlCompilerContext context, SqlAlterTable node, AlterTableSection section)
        {
            switch (section)
            {
            case AlterTableSection.AddColumn:
                return("ADD");

            case AlterTableSection.AlterColumn:
                return("ALTER");

            case AlterTableSection.DropColumn:
                return("DROP");

            case AlterTableSection.RenameColumn:
                return("ALTER");

            case AlterTableSection.DropBehavior:
                return(string.Empty);
            }
            return(base.Translate(context, node, section));
        }
Ejemplo n.º 2
0
        public override string Translate(SqlCompilerContext context, SqlAlterTable node, AlterTableSection section)
        {
            switch (section)
            {
            case AlterTableSection.DropBehavior:
                var cascadableAction = node.Action as SqlCascadableAction;
                if (cascadableAction == null || !cascadableAction.Cascade)
                {
                    return(string.Empty);
                }
                if (cascadableAction is SqlDropConstraint)
                {
                    return(string.Empty);
                }
                return(cascadableAction.Cascade ? "CASCADE" : "RESTRICT");

            default:
                return(base.Translate(context, node, section));
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public override string Translate(SqlCompilerContext context, SqlAlterTable node, AlterTableSection section)
        {
            switch (section)
            {
            case AlterTableSection.Entry:
                return("ALTER TABLE " + Translate(context, node.Table));

            case AlterTableSection.AddColumn:
                return("ADD");

            case AlterTableSection.Exit:
                return(string.Empty);

            default:
                throw SqlHelper.NotSupported(node.Action.GetType().Name);
            }
        }
Ejemplo n.º 4
0
        public override string Translate(SqlCompilerContext context, SqlAlterTable node, AlterTableSection section)
        {
            switch (section)
            {
            case AlterTableSection.AddColumn:
                return("ADD");

            case AlterTableSection.DropBehavior:
                var cascadableAction = node.Action as SqlCascadableAction;
                if (cascadableAction == null || !cascadableAction.Cascade)
                {
                    return(string.Empty);
                }
                if (cascadableAction is SqlDropConstraint)
                {
                    return("CASCADE");
                }
                if (cascadableAction is SqlDropColumn)
                {
                    return("CASCADE CONSTRAINTS");
                }
                throw new ArgumentOutOfRangeException("node.Action");

            default:
                return(base.Translate(context, node, section));
            }
        }