Inheritance Mapping
ℹ️ Description: Use IncludeBase() to map inherited properties from base classes.
Manager Information
Base Employee Properties
| Property | Value |
|---|---|
| Id | 1 |
| Name | Sarah Johnson |
| sarah.johnson@example.com | |
| Department | Engineering |
Manager-Specific Properties
| Property | Value |
|---|---|
| Team Size | 12 people |
| Office Location | Building A, Floor 3 |
🏗️ Inheritance Mapping Explained
// Domain Models
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
// ... other properties
}
public class Manager : Employee
{
public int TeamSize { get; set; }
public string OfficeLocation { get; set; }
}
// DTOs with same inheritance
public class EmployeeDTO { ... }
public class ManagerDTO : EmployeeDTO { ... }
// Mapping configuration
CreateMap<Employee, EmployeeDTO>();
CreateMap<Manager, ManagerDTO>()
.IncludeBase<Employee, EmployeeDTO>(); // Include base class mappings
Result: Manager is mapped to ManagerDTO with all base Employee properties included automatically!