private void ProcessEntityTablePerSubClass(Entity entity, joinedsubclass joinedSubClassNode) { foreach (var childEntity in entity.Children) { var mappedTable = childEntity.MappedTables().First(); var subclassNode = new joinedsubclass(); subclassNode.table = mappedTable.Name.BackTick(); subclassNode.schema = mappedTable.Schema.BackTick(); subclassNode.name = childEntity.Name; key keyNode = GetKeyNode(mappedTable); subclassNode.key = keyNode; foreach (var property in childEntity.ConcreteProperties) { IColumn column = property.MappedColumn(); if (column == null) { continue; } property propNode = ProcessProperty(property, column); subclassNode.AddProperty(propNode); } joinedSubClassNode.AddJoinedSubclass(subclassNode); var referenceMapper = new ReferenceMapper(); referenceMapper.ProcessReferences(childEntity, item => subclassNode.AddItem(item)); } }
private void ProcessInheritance(Entity entity, joinedsubclass newJoinedSubClass) { EntityImpl.InheritanceType inheritanceType = EntityImpl.DetermineInheritanceTypeWithChildren(entity); switch (inheritanceType) { case EntityImpl.InheritanceType.None: case EntityImpl.InheritanceType.TablePerConcreteClass: // Table per concrete class doesn't need special treatment. break; case EntityImpl.InheritanceType.TablePerClassHierarchy: // All child entities are mapped to the same table as the parent. //ProcessEntityTablePerClassHierarchy(entity, newJoinedSubClass); break; case EntityImpl.InheritanceType.TablePerSubClass: ProcessEntityTablePerSubClass(entity, newJoinedSubClass); break; case EntityImpl.InheritanceType.Unsupported: throw new Exception("An unsupported inheritance structure was detected. " + "We only support Table Per Class Hierarchy, Table Per Sub Class, and Table Per Concrete Class. " + "See the NHibernate documentation for more details."); default: throw new ArgumentOutOfRangeException(); } }
public static void AddItem(this joinedsubclass theClass, object property) { if (theClass.Items == null) { theClass.Items = new object[0]; } object[] items = theClass.Items; Array.Resize(ref items, theClass.Items.Length + 1); items[items.Length - 1] = property; theClass.Items = items; }
public static void AddJoinedSubclass(this joinedsubclass theJoinedSubclass, joinedsubclass child) { if (theJoinedSubclass.joinedsubclass1 == null) { theJoinedSubclass.joinedsubclass1 = new joinedsubclass[0]; } joinedsubclass[] items = theJoinedSubclass.joinedsubclass1; Array.Resize(ref items, theJoinedSubclass.joinedsubclass1.Length + 1); items[items.Length - 1] = child; theJoinedSubclass.joinedsubclass1 = items; }
/// <summary> /// Gets a collection of properties in the subclass /// </summary> /// <param name="theClass"></param> /// <returns></returns> public static IEnumerable <property> Properties(this joinedsubclass theClass) { if (theClass.Items == null) { yield break; } foreach (var item in theClass.Items) { if (item is property) { yield return(item as property); } } }