예제 #1
0
 public Column(EntityTable table, string name)
 {
     Table        = table;
     Restrictions = new List <Restriction>();
     Parameters   = new List <Parameter>();
     Name         = name;
     Alias        = $"{table.Type.Name}.{Name}";
     PropertyName = string.Empty;
     PropertyType = typeof(object);
 }
예제 #2
0
        public EntityColumn(ColumnAttribute columnAttribute, EntityTable table)
            : base(table, columnAttribute.ColumnName)
        {
            ColumnAttribute = columnAttribute;
            ColumnType      = ColumnTypes.EntityColumn;
            DataColumn      = new DataColumn(Name);

            GetPropertyInfo();

            Logger.Trace($"Loaded database mapping for Property '{PropertyName}' of Entity '{Table.Type.Name}' (Column '{Name}')");
        }
예제 #3
0
        public FormulaColumn(FormulaAttribute formulaAttribute, EntityTable table)
            : base(table, formulaAttribute.Alias)
        {
            FormulaAttribute = formulaAttribute;
            Alias            = Name;
            Formula          = formulaAttribute.Query;
            ColumnType       = ColumnTypes.FormulaColumn;

            GetPropertyInfo();

            Logger.Trace($"Loaded database mapping for Property '{PropertyName}' of Entity '{Table.Type.Name}' (Column '{Name}')");
        }
예제 #4
0
        internal void UpdateForeignKeys(dynamic primaryKey, int entityIndex)
        {
            Logger.Trace($"Updating foreign keys of child entities of '{Type.Name}' entity");

            IEntity entity = Entities[entityIndex];

            foreach (IEntity childEntity in entity.GetChildren())
            {
                Type        type  = childEntity.GetType();
                EntityTable table = Mapping.TypeTableMapping[type];
                table.SetForeignKeyValue(childEntity, primaryKey);
            }
        }
예제 #5
0
        protected bool TryGetTable(Type type, out EntityTable?table)
        {
            AttributeWrapper attributes = new AttributeWrapper(type);

            if (attributes.IsValid())
            {
                table = new EntityTable(type, attributes);
                return(true);
            }

            table = null;
            return(false);
        }
예제 #6
0
        protected void MapTablesByProperty(PropertyInfo property, EntityTable parentTable)
        {
            Type propertyType = property.PropertyType;

            // If the property is a generic list, then it fits the profile of a child object
            if (ReflectionUtil.IsGenericList(propertyType))
            {
                Type genericArgumentType = propertyType.GetGenericArguments()[0];

                MapType(genericArgumentType);

                EntityTable mappedTable = TypeTableMapping[genericArgumentType];

                mappedTable.ParentTable = parentTable;
                parentTable.ChildTables.Add(mappedTable);
            }
        }
예제 #7
0
        protected void MapType(Type type)
        {
            if (!TypeTableMapping.ContainsKey(type))
            {
                EntityTable table = GetTableByType(type);

                table.Mapping = this;

                Tables.Add(table);
                TypeTableMapping.Add(type, table);

                foreach (PropertyInfo prop in type.GetProperties())
                {
                    MapTablesByProperty(prop, table);
                }
            }
        }
예제 #8
0
 public EntityColumn GetForeignKeyColumnFor(EntityTable foreignTable)
 {
     return(foreignKeyColumnsDict[foreignTable.Name] ?? throw new TableMappingException(Type, Name));
 }