本文整理汇总了C#中NHibernate.Mapping.Table.CreateForeignKeys方法的典型用法代码示例。如果您正苦于以下问题:C# Table.CreateForeignKeys方法的具体用法?C# Table.CreateForeignKeys怎么用?C# Table.CreateForeignKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.Table
的用法示例。
在下文中一共展示了Table.CreateForeignKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SecondPassCompileForeignKeys
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);
}
}
}
}
}