Julian Gonzalez

Generation

generate functionSat, 01 Apr 2023

map objects c# with automapper library

public class Customer { public string Name { get; set; } public string Address { get; set; } } public class CustomerDto { public string Name { get; set; } public string Address { get; set; } } // mapper config var config = new MapperConfiguration(cfg => { cfg.CreateMap<Customer, CustomerDto>(); }); var mapper = config.CreateMapper(); // do your mapping return mapper.Map<CustomerDto>(customer);

Questions about programming?Chat with your personal AI assistant