示例#1
0
        public virtual void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
                                          string[] refColumns, ForeignKeyConstraint constraint)
        {
            if (ConstraintExists(primaryTable, name))
            {
                Logger.Warn("Constraint {0} already exists", name);
                return;
            }

            string constraintResolved = constraintMapper.SqlForConstraint(constraint);

            ExecuteNonQuery(
                String.Format(
                    "ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4}) ON UPDATE {5} ON DELETE {6}",
                    primaryTable, name, String.Join(",", primaryColumns),
                    refTable, String.Join(",", refColumns), constraintResolved, constraintResolved));
        }
		public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint) {
			GenerateForeignKey(primaryTable, refTable + "Id", refTable, "Id", constraint);
		}
		public virtual void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
		                                  string[] refColumns, ForeignKeyConstraint constraint) {
			if (ConstraintExists(primaryTable, name)) {
				Logger.Warn("Constraint {0} already exists", name);
				return;
			}

			string constraintResolved = constraintMapper.SqlForConstraint(constraint);
			ExecuteNonQuery(
				String.Format(
					"ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4}) ON UPDATE {5} ON DELETE {6}",
					primaryTable, name, String.Join(",", primaryColumns),
					refTable, String.Join(",", refColumns), constraintResolved, constraintResolved));
		}
		public virtual void AddForeignKey(string name, string primaryTable, string primaryColumn, string refTable,
		                                  string refColumn, ForeignKeyConstraint constraint) {
			AddForeignKey(name, primaryTable, new string[] {primaryColumn}, refTable, new string[] {refColumn},
			              constraint);
		}
		/// <summary>
		///   Guesses the name of the foreign key and add it
		///   </see>
		/// </summary>
		public virtual void GenerateForeignKey(string primaryTable, string[] primaryColumns, string refTable,
		                                       string[] refColumns, ForeignKeyConstraint constraint) {
			AddForeignKey("FK_" + primaryTable + "_" + refTable, primaryTable, primaryColumns, refTable, refColumns,
			              constraint);
		}
示例#6
0
 public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint)
 {
     GenerateForeignKey(primaryTable, refTable + "Id", refTable, "Id", constraint);
 }
示例#7
0
 public virtual void AddForeignKey(string name, string primaryTable, string primaryColumn, string refTable,
                                   string refColumn, ForeignKeyConstraint constraint)
 {
     AddForeignKey(name, primaryTable, new string[] { primaryColumn }, refTable, new string[] { refColumn },
                   constraint);
 }
示例#8
0
 /// <summary>
 ///   Guesses the name of the foreign key and add it
 ///   </see>
 /// </summary>
 public virtual void GenerateForeignKey(string primaryTable, string[] primaryColumns, string refTable,
                                        string[] refColumns, ForeignKeyConstraint constraint)
 {
     AddForeignKey("FK_" + primaryTable + "_" + refTable, primaryTable, primaryColumns, refTable, refColumns,
                   constraint);
 }
 public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint)
 {
     // No Op
 }
 public void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
                           string[] refColumns, ForeignKeyConstraint constraint)
 {
     // No Op
 }
		public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint) {
			// No Op
		}
		public void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
		                          string[] refColumns, ForeignKeyConstraint constraint) {
			// No Op
		}