I have a below MappingProfile
. It is working fine. But do you know how to write it in a single line or a more concise manner?
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<ExpenseDto, Expense>().ForMember(expense => expense.Image,
opt => opt.MapFrom(expenseDto => Convert.FromBase64String(expenseDto.Image)));
CreateMap<Expense, ExpenseDto>().ForMember(expenseDto => expenseDto.Image,
opt => opt.MapFrom(expense => Convert.ToBase64String(expense.Image)));
}
}
Expense Entity
public class Expense
{
public byte[]? Image { get; set; }
}
Expense Dto
public record ExpenseDto
{
public string? Image { get; init; }
}