Ejemplo n.º 1
0
        /// <summary>
        /// Get the SQL string to drop this Constraint in the database.
        /// </summary>
        /// <param name="dialect">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
        /// <param name="defaultCatalog"></param>
        /// <param name="defaultSchema"></param>
        /// <returns>
        /// A string that contains the SQL to drop this Constraint.
        /// </returns>
        public override string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
        {
            string ifExists = dialect.GetIfExistsDropConstraint(Table, Name);
            string drop     = string.Format("alter table {0}{1}", Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), dialect.GetDropPrimaryKeyConstraintString(Name));
            string end      = dialect.GetIfExistsDropConstraintEnd(Table, Name);

            return(ifExists + Environment.NewLine + drop + Environment.NewLine + end);
        }
Ejemplo n.º 2
0
        public static string BuildSqlDropIndexString(Dialect.Dialect dialect, Table table, string name, string defaultCatalog, string defaultSchema)
        {
            string ifExists = dialect.GetIfExistsDropConstraint(table, name);
            string drop     = string.Format("drop index {0}", StringHelper.Qualify(table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), name));
            string end      = dialect.GetIfExistsDropConstraintEnd(table, name);

            return(ifExists + Environment.NewLine + drop + Environment.NewLine + end);
        }
Ejemplo n.º 3
0
        public static string BuildSqlDropIndexString(Dialect.Dialect dialect, Table table, string name, string defaultCatalog, string defaultSchema)
        {
            var catalog   = table.GetQuotedCatalog(dialect, defaultCatalog);
            var schema    = table.GetQuotedSchema(dialect, defaultSchema);
            var tableName = table.GetQuotedName(dialect);

            return(new StringBuilder()
                   .AppendLine(dialect.GetIfExistsDropConstraint(catalog, schema, tableName, name))
                   .Append("drop index ")
                   .AppendLine(StringHelper.Qualify(table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), name))
                   .Append(dialect.GetIfExistsDropConstraintEnd(catalog, schema, tableName, name))
                   .ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get the SQL string to drop this Constraint in the database.
        /// </summary>
        /// <param name="dialect">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
        /// <param name="defaultCatalog"></param>
        /// <param name="defaultSchema"></param>
        /// <returns>
        /// A string that contains the SQL to drop this Constraint.
        /// </returns>
        public override string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
        {
            var catalog   = Table.GetQuotedCatalog(dialect, defaultCatalog);
            var schema    = Table.GetQuotedSchema(dialect, defaultSchema);
            var tableName = Table.GetQuotedName(dialect);

            return(new StringBuilder()
                   .AppendLine(dialect.GetIfExistsDropConstraint(catalog, schema, tableName, Name))
                   .Append("alter table ")
                   .Append(Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema))
                   .AppendLine(dialect.GetDropPrimaryKeyConstraintString(Name))
                   .Append(dialect.GetIfExistsDropConstraintEnd(catalog, schema, tableName, Name))
                   .ToString());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the SQL string to drop this Constraint in the database.
        /// </summary>
        /// <param name="dialect">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
        /// <param name="defaultSchema"></param>
        /// <param name="defaultCatalog"></param>
        /// <returns>
        /// A string that contains the SQL to drop this Constraint.
        /// </returns>
        public virtual string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
        {
            if (IsGenerated(dialect))
            {
                string ifExists = dialect.GetIfExistsDropConstraint(Table, Name);
                string drop     =
                    string.Format("alter table {0} drop constraint {1}", Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), Name);
                string end = dialect.GetIfExistsDropConstraintEnd(Table, Name);

                return(ifExists + System.Environment.NewLine + drop + System.Environment.NewLine + end);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Generates the SQL string to drop this Constraint in the database.
        /// </summary>
        /// <param name="dialect">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
        /// <param name="defaultSchema"></param>
        /// <param name="defaultCatalog"></param>
        /// <returns>
        /// A string that contains the SQL to drop this Constraint.
        /// </returns>
        public virtual string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
        {
            if (!IsGenerated(dialect))
            {
                return(null);
            }

            var catalog   = Table.GetQuotedCatalog(dialect, defaultCatalog);
            var schema    = Table.GetQuotedSchema(dialect, defaultSchema);
            var tableName = Table.GetQuotedName(dialect);

            return(new StringBuilder()
                   .AppendLine(dialect.GetIfExistsDropConstraint(catalog, schema, tableName, Name))
                   .Append("alter table ")
                   .Append(Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema))
                   .Append(" drop constraint ")
                   .AppendLine(Name)
                   .Append(dialect.GetIfExistsDropConstraintEnd(catalog, schema, tableName, Name))
                   .ToString());
        }