Example #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;
		}
Example #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;
		}
Example #3
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 useCatalog = "";
     if (!String.IsNullOrEmpty(Table.Catalog))
     {
         useCatalog = string.Format("use {0} ", Table.Catalog);
     }
     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 useCatalog + ifExists + Environment.NewLine + drop + Environment.NewLine + end;
 }
Example #4
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;
			}
		}