Example #1
0
        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();
            }
        }
Example #2
0
        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));
            }
        }