本文整理汇总了C#中NHibernate.Mapping.PersistentClass.GetInheritanceType方法的典型用法代码示例。如果您正苦于以下问题:C# PersistentClass.GetInheritanceType方法的具体用法?C# PersistentClass.GetInheritanceType怎么用?C# PersistentClass.GetInheritanceType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.PersistentClass
的用法示例。
在下文中一共展示了PersistentClass.GetInheritanceType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFirstPass
public void GenerateFirstPass(PersistentClass pc, ClassAuditingData auditingData,
EntityXmlMappingData xmlMappingData, bool isAudited)
{
var schema = GetSchema(auditingData.AuditTable.Schema, pc.Table);
var catalog = GetCatalog(auditingData.AuditTable.Catalog, pc.Table);
var entityName = pc.EntityName;
if (!isAudited)
{
var _idMapper = idMetadataGenerator.AddId(pc);
if (_idMapper == null)
{
// Unsupported id mapping, e.g. key-many-to-one. If the entity is used in auditing, an exception
// will be thrown later on.
if (log.IsDebugEnabled)
{
log.DebugFormat("Unable to create auditing id mapping for entity {0}" +
", because of an unsupported Hibernate id mapping (e.g. key-many-to-one).", entityName);
}
return;
}
//ORIG:
//IExtendedPropertyMapper propertyMapper = null;
//String parentEntityName = null;
var _entityCfg = new EntityConfiguration(entityName, pc.ClassName, _idMapper, null, null);
NotAuditedEntitiesConfigurations.Add(entityName, _entityCfg);
return;
}
if (log.IsDebugEnabled)
{
log.DebugFormat("Generating first-pass auditing mapping for entity {0}.", entityName);
}
var auditEntityName = VerEntCfg.GetAuditEntityName(entityName);
var auditTableName = VerEntCfg.GetAuditTableName(entityName, pc.Table.Name);
// Registering the audit entity name, now that it is known
AuditEntityNameRegister.Register(auditEntityName);
var auditTableData = new AuditTableData(auditEntityName, auditTableName, schema, catalog);
// Generating a mapping for the id
var idMapper = idMetadataGenerator.AddId(pc);
var inheritanceType = pc.GetInheritanceType();
// These properties will be read from the mapping data
Triple<XmlElement, IExtendedPropertyMapper, string> mappingData;
// Reading the mapping data depending on inheritance type (if any)
switch (inheritanceType)
{
case InheritanceType.None:
mappingData = GenerateMappingData(pc, xmlMappingData, auditTableData, idMapper);
break;
case InheritanceType.Single:
auditTableData = new AuditTableData(auditEntityName, null, schema, catalog);
mappingData = GenerateInheritanceMappingData(pc, xmlMappingData, auditTableData, "subclass");
break;
case InheritanceType.Joined:
mappingData = GenerateInheritanceMappingData(pc, xmlMappingData, auditTableData, "joined-subclass");
// Adding the "key" element with all id columns...
var keyMapping = mappingData.First.OwnerDocument.CreateElement("key");
mappingData.First.AppendChild(keyMapping);
MetadataTools.AddColumns(keyMapping, pc.Table.PrimaryKey.ColumnIterator);
// ... and the revision number column, read from the revision info relation mapping.
keyMapping.AppendChild(CloneAndSetupRevisionInfoRelationMapping(keyMapping.OwnerDocument).GetElementsByTagName("column")[0].Clone());
break;
case InheritanceType.TablePerClass:
mappingData = GenerateInheritanceMappingData(pc, xmlMappingData, auditTableData, "union-subclass");
break;
default:
throw new AssertionFailure("AuditMetadataGenerator.GenerateFirstPass: Impossible enum value.");
}
var class_mapping = mappingData.First;
var propertyMapper = mappingData.Second;
var parentEntityName = mappingData.Third;
xmlMappingData.ClassMapping = class_mapping;
// Mapping unjoined properties
AddProperties(class_mapping, pc.UnjoinedPropertyIterator, propertyMapper,
auditingData, pc.EntityName, xmlMappingData,
true);
// Creating and mapping joins (first pass)
CreateJoins(pc, class_mapping, auditingData);
AddJoins(pc, propertyMapper, auditingData, pc.EntityName, xmlMappingData, true);
//.........这里部分代码省略.........