0

How to use new automapper v4 configs ? An ex:

MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg => cfg.CreateMap<PersonModel, Person>());

mapperConfiguration = new MapperConfiguration(cfg => cfg.CreateMap<PersonModel, Person>());

But this is not the way as you can see. I'm creating new MapperConfiguration again, so first configuration will be gone. I'm a little bit tried now maybe I'm not carefull but it looks complex to me.

Old times, you can do that;

Mapper.CreateMap<Person, PersonModel>();
Mapper.CreateMap<PersonModel, Person>();

What am I missing ?

Lost_In_Library
  • 3,265
  • 6
  • 38
  • 70

1 Answers1

1

It was simple, sorry. Here is the code;

MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg =>
{
    cfg.CreateMap<PersonModel, Person>();
    cfg.CreateMap<Person, PersonModel>();
});
Rob
  • 26,989
  • 16
  • 82
  • 98
Lost_In_Library
  • 3,265
  • 6
  • 38
  • 70