ConvertTo & IMapFrom Mapping
Streamlining Object Mapping, AutoMapper Integration, and View Model Transformations in AUA
Models and Mapping Architecture
Due to the complexity of software systems, mapping entities to Data Transfer Objects (DTOs) or custom View Models is a core pillar. The AUA framework simplifies this process using built-in interfaces like IMapFrom and IHaveCustomMappings, backed by AutoMapper instances across all services.
ConvertTo Method
Developers can effortlessly convert an object or a list of objects into target view models without friction using the built-in ConvertTo and ProjectTo functions directly inside services.
IHaveCustomMappings for complex property adjustments.
IMapFrom Interface
Maps fields of the same name automatically between entities and DTOs with zero configuration overhead. Models inherit from BaseEntityDto, ensuring structural consistency.
FullName) are ideally placed directly inside the DTO layer.
1. Simple Entity to DTO Mapping (IMapFrom)
In this example, the StudentDto inherits from BaseEntityDto and implements IMapFrom<Student> to automatically map matching properties without extra configuration.
public class StudentDto : BaseEntityDto, IMapFrom<Student>
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
// Calculated properties are best placed directly in the DTO
public string FullName => $"{FirstName} {LastName}";
}
"If you think good architecture is expensive, try bad architecture."AUA Framework Philosophy