Пример #1
0
        public override void CreateForeignKeys()
        {
            includedTable.CreateForeignKeys();
            IEnumerable includedFks = includedTable.ForeignKeyIterator;

            foreach (ForeignKey fk in includedFks)
            {
                // NH Different behaviour (fk name)
                CreateForeignKey(GetForeignKeyName(fk), fk.Columns, fk.ReferencedEntityName);
            }
        }
Пример #2
0
        public override void CreateForeignKeys()
        {
            includedTable.CreateForeignKeys();
            var includedFks = includedTable.ForeignKeyIterator;

            foreach (var fk in includedFks)
            {
                CreateForeignKey(
                    Constraint.GenerateName(
                        fk.GeneratedConstraintNamePrefix,
                        this,
                        null,
                        fk.Columns),
                    fk.Columns, fk.ReferencedEntityName);
            }
        }
Пример #3
0
		private void SecondPassCompileForeignKeys(Table table, ISet done)
		{
			table.CreateForeignKeys();

			foreach (ForeignKey fk in table.ForeignKeyIterator)
			{
				if (!done.Contains(fk))
				{
					done.Add(fk);

					string referencedEntityName = fk.ReferencedEntityName;
					if (string.IsNullOrEmpty(referencedEntityName))
					{
						throw new MappingException(string.Format("An association from the table {0} does not specify the referenced entity", fk.Table.Name));
					}

					if (log.IsDebugEnabled)
					{
						log.Debug("resolving reference to class: " + referencedEntityName);
					}

					PersistentClass referencedClass;
					if (!classes.TryGetValue(referencedEntityName, out referencedClass))
					{
						string message = string.Format("An association from the table {0} refers to an unmapped class: {1}",
							fk.Table.Name, referencedEntityName);

						LogAndThrow(new MappingException(message));
					}
					else
					{
						if (referencedClass.IsJoinedSubclass)
						{
							SecondPassCompileForeignKeys(referencedClass.Superclass.Table, done);
						}

						try
						{
							fk.ReferencedTable = referencedClass.Table;
							fk.AlignColumns();
						}
						catch (MappingException me)
						{
							LogAndThrow(me);
						}
					}
				}
			}
		}