This might be a basic question but wondering I am not getting AutoMapper.Mapper.CreateMap method.
Am I using wrong AutoMapper reference/package? Thanks
If you have to do complex mapping behavior, it might be better to avoid using AutoMapper for that scenario. Reverse mapping can get very complicated very quickly, and unless it's very simple, you can have business logic showing up in mapping configuration.
AutoMapper in C# is a library used to map data from one object to another. It acts as a mapper between two objects and transforms one object type into another. It converts the input object of one type to the output object of another type until the latter type follows or maintains the conventions of AutoMapper.
The static version of the CreateMap
method was deprecated in 4.2, then removed from the API in version 5.0. Jimmy Bogard talks about this in more detail in this blog post.
The new technique for mapping is non-static, like this (code is from the post):
var config = new MapperConfiguration(cfg => { cfg.CreateMap<Source, Dest>(); }); IMapper mapper = config.CreateMapper(); var source = new Source(); var dest = mapper.Map<Source, Dest>(source);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With