Wanted to use AutoMapper to deal with some 'monkey' code. It works right of the bat; now looking to set up all the mapping in one place. So, I have:
- A static class AutoMapperConfiguration in AppStart folder.
- A static Configure method in which I call Mapper.Initialize(). I call Configure() from Global.axax.cs
In controller, I proceed to use Mapper.Map(src obj, dest obj). However, this gives me a Unmapped properties exception.
When I use CreateMap inside a MappingConfiguration variable and do iMapper.Map(), it is working. Is this the right way to do it? If so, how to configure and use it from a single location? Can I use unity container?
unityContainer.RegisterInstance<IMapper>(AutoMapperConfiguration.config.CreateMapper());
in unityConfig and injecting the IMapper to controller is working, but I'm not sure how – Shwrk