Basic Mapping Example

ℹ️ Description: AutoMapper automatically maps properties with the same name and compatible types.

Mapping Result

Property Value
Id 1
Name John Doe
Email john.doe@example.com
Department IT
💻 Code Used
// Source object
var employee = new Employee
{
    Id = 1,
    Name = "John Doe",
    Email = "john.doe@example.com",
    Department = "IT"
};

// Map to DTO
var employeeDTO = _mapper.Map<EmployeeDTO>(employee);

// AutoMapper automatically maps properties with the same name!