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

            ExecuteNonQuery(
                String.Format(
                    "ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4})",
                    primaryTable, name, String.Join(",", primaryColumns),
                    refTable, String.Join(",", refColumns)));
        }
コード例 #2
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));
        }
コード例 #3
0
        public override void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
                                           string[] refColumns, ForeignKeyConstraint constraint)
        {
            GuardAgainstMaximumIdentifierLengthForOracle(name);

            if (ConstraintExists(primaryTable, name))
            {
                Logger.Warn("Constraint {0} already exists", name);
                return;
            }

            primaryTable = QuoteTableNameIfRequired(primaryTable);
            refTable     = QuoteTableNameIfRequired(refTable);
            string primaryColumnsSql = String.Join(",", primaryColumns.Select(col => QuoteColumnNameIfRequired(col)).ToArray());
            string refColumnsSql     = String.Join(",", refColumns.Select(col => QuoteColumnNameIfRequired(col)).ToArray());

            ExecuteNonQuery(String.Format("ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4})", primaryTable, name, primaryColumnsSql, refTable, refColumnsSql));
        }
コード例 #4
0
		public override void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
		                                   string[] refColumns, ForeignKeyConstraint constraint)
		{
			GuardAgainstMaximumIdentifierLengthForOracle(name);

			if (ConstraintExists(primaryTable, name))
			{
				Logger.Warn("Constraint {0} already exists", name);
				return;
			}

			primaryTable = QuoteTableNameIfRequired(primaryTable);
			refTable = QuoteTableNameIfRequired(refTable);
			string primaryColumnsSql = String.Join(",", primaryColumns.Select(col => QuoteColumnNameIfRequired(col)).ToArray());
			string refColumnsSql = String.Join(",", refColumns.Select(col => QuoteColumnNameIfRequired(col)).ToArray());

			ExecuteNonQuery(String.Format("ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4})", primaryTable, name, primaryColumnsSql, refTable, refColumnsSql));
		}
コード例 #5
0
			GenerateForeignKey(primaryTable, refTable, ForeignKeyConstraint.NoAction);
		}

		public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint)
コード例 #6
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));
		}
コード例 #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);
		}
コード例 #9
0
		public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint)
		{
			// No Op
		}
コード例 #10
0
		public void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
		                          string[] refColumns, ForeignKeyConstraint constraint)
		{
			// No Op
		}
コード例 #11
0
 public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint)
 {
     // No Op
 }
コード例 #12
0
 public void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
                           string[] refColumns, ForeignKeyConstraint constraint)
 {
     // No Op
 }
コード例 #13
0
 public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraint constraint)
 {
     GenerateForeignKey(primaryTable, refTable + "Id", refTable, "Id", constraint);
 }
コード例 #14
0
 public void AddForeignKey(string name, string foreignTable, string foreignColumn, string primaryTable, string primaryColumn, ForeignKeyConstraint constraint)
 {
     _sqlServerTransformationProvider.AddForeignKey(name, foreignTable, foreignColumn, primaryTable, primaryColumn, constraint);
 }
コード例 #15
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);
 }
コード例 #16
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);
 }
コード例 #17
0
		public override void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
		                                   string[] refColumns, ForeignKeyConstraint constraint)
		{
			// NOOP Because SQLite doesn't support foreign keys
		}
コード例 #18
0
 public override void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable,
                                    string[] refColumns, ForeignKeyConstraint constraint)
 {
     // NOOP Because SQLite doesn't support foreign keys
 }
コード例 #19
0
 public void GenerateForeignKey(string foreignTable, string primaryTable, ForeignKeyConstraint constraint)
 {
     _sqlServerTransformationProvider.GenerateForeignKey(foreignTable, primaryTable, constraint);
 }