Esempio n. 1
0
        public static void AddForeignKeyColumn(ForeignKey foreignKey, ForeignKeyColumn foreignKeyColumn)
        {
            if (foreignKeyColumn.ForeignKey != null && foreignKeyColumn.ForeignKey.Equals(foreignKey))
            {
                RemoveForeignKeyColumn(foreignKeyColumn.ForeignKey, foreignKeyColumn);
            }

            if (foreignKey.ForeignKeyColumns.Count > 0)
            {
                var firstForeignKeyColumn = foreignKey.ForeignKeyColumns.First();
                if (!firstForeignKeyColumn.ReferencedUserTable.Equals(foreignKeyColumn.ReferencedUserTable))
                {
                    throw new Exception(string.Format("{0} {1} does not reference the same {2} as {3} {4}.",
                                                      foreignKeyColumn.Description, foreignKeyColumn.Namespace, foreignKeyColumn.ReferencedUserTable.Description,
                                                      firstForeignKeyColumn.Description, firstForeignKeyColumn.Namespace));
                }
            }

            foreignKey.ForeignKeyColumns.Add(foreignKeyColumn);
        }
Esempio n. 2
0
 public static void RemoveForeignKeyColumn(ForeignKey foreignKey, ForeignKeyColumn foreignKeyColumn)
 {
     foreignKey.ForeignKeyColumns.Remove(foreignKeyColumn.Namespace);
 }