本文整理匯總了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);
}
}
}
}
}