namespace AutoMapperConsoleApp
public string? Property1 { get; set; }
public int Quantity { get; set; } = 1;
public class DataQuantity
public Data Data { get; set; } = null !;
public int Quantity { get; set; } = 1;
static void Main(string[] args)
var config = new MapperConfiguration(cfg =>
cfg.CreateMap<DataQuantity, Data>();
IMapper mapper = config.CreateMapper();
var dataqty = new DataQuantity{Data = new Data{Property1 = "prop1"}, Quantity = 3};
var data = mapper.Map<Data>(dataqty);
Console.WriteLine("Mapped object:");
Console.WriteLine($"Property1: {data.Property1}");
Console.WriteLine($"Quantity: {data.Quantity}");