public class Source
{
public int Value1 { get; set; }
public int Value2 { get; set; }
}
public class Destination
{
public int Total { get; set; }
}
Mapper.Initialize(cfg =>
{
cfg.CreateMap()
.ForMember(dest => dest.Total, opt => opt.MapFrom(src => src.Value1 + src.Value2));
});
var source = new Source { Value1 = 5, Value2 = 10 };
var destination = Mapper.Map(source);
Console.WriteLine(destination.Total); // Output: 15