automapper code example

Example 1: dto and automapper

public TeamDTO GetByID(int id)
{
    var team = ... //Get Team entity from data store
    return Mapper.Map<TeamDTO>(team);
}

Example 2: c# mapper.map

var config = new MapperConfiguration(cfg => {                cfg.CreateMap<AuthorModel, AuthorDTO>();            });IMapper iMapper = config.CreateMapper();var source = new AuthorModel();source.Id = 1;source.FirstName = "Joydip";source.LastName = "Kanjilal";source.Address = "India";var destination = iMapper.Map<AuthorModel, AuthorDTO>(source);Console.WriteLine("Author Name: "+ destination.FirstName + " " + destination.LastName);