Custom Value Resolvers
ℹ️ Description: Use IValueResolver for complex property mapping logic that requires context or calculations.
Mapping Result
| Property | Value |
|---|---|
| Id | 1 |
| First Name | John |
| Last Name | Doe |
| Full Name Computed | |
| john.doe@example.com | |
| Date of Birth Formatted | |
| Age Calculated | 0 years |
| Total Orders | 0 |
| Status Resolver |
💻 Code Used
// Create source object
var user = new User
{
Id = 1,
FirstName = "John",
LastName = "Doe",
Email = "john.doe@example.com",
DateOfBirth = new DateTime(1990, 1, 1),
// ... other properties
};
// Map to DTO using AutoMapper
var userDTO = _mapper.Map<UserDTO>(user);
// That's it! AutoMapper handles all the mapping logic