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); }
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}')"); }
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}')"); }
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); } }
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); }
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); } }
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); } } }
public EntityColumn GetForeignKeyColumnFor(EntityTable foreignTable) { return(foreignKeyColumnsDict[foreignTable.Name] ?? throw new TableMappingException(Type, Name)); }