Habanero.Smooth.InheritanceAutoMapper.Map C# (CSharp) Method

Map() public method

public Map ( ) : ISuperClassDef
return ISuperClassDef
        public ISuperClassDef Map()
        {
            if (MustBeMapped())
            {
                var baseType = this.TypeWrapper.BaseType;

                var superClassInheritanceRel = baseType.MapInheritance();
                var superClassDef = baseType.MapClass();
                ISuperClassDef inheritanceDef;
                if (superClassDef != null)
                {
                    if (superClassInheritanceRel != null)
                    {
                        superClassDef.SuperClassDef = superClassInheritanceRel;
                    }
                    inheritanceDef = new SuperClassDef(superClassDef, ORMapping.SingleTableInheritance);

                    //If this is the Most Base Type i.e. it 
                    // does not have another Business object as its super class
                    // then you should create the discriminator Property
                    if (superClassInheritanceRel == null)
                    {
                        inheritanceDef.Discriminator = superClassDef.ClassName + "Type";
                        CreateDiscriminatorProp(inheritanceDef);
                    }else
                    {
                        inheritanceDef.Discriminator = superClassInheritanceRel.Discriminator;
                    }
                    return inheritanceDef;
                }

            }
            return null;
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Maps any Inhertiance Relationships for the <paramref name="typeWrapper"/>.
        /// and returns the <see cref="ISuperClassDef"/> that is used to
        /// map these in Habanero.
        /// </summary>
        public static ISuperClassDef MapInheritance(this TypeWrapper typeWrapper)
        {
            if (typeWrapper.IsNull())
            {
                return(null);
            }
            InheritanceAutoMapper autoMapper = new InheritanceAutoMapper(typeWrapper);

            return(autoMapper.Map());
        }
All Usage Examples Of Habanero.Smooth.InheritanceAutoMapper::Map