maio 10, 2019
How to reduce inefficiencies with AutoMapper for Sitecore
While working on one of our projects, I realized that every time developers needed to map a model (object) to another one, they had to copy each and every field from one object to another.
I looked for a solution to reduce this inefficiency, and realized that a very useful tool exists to accelerate the developers’ process. So, I introduced “AutoMapper” .Net Nuget Package to the team. I added the package, configured it, and used it in the solution.
Setting up Auto Mapper in Sitecore was easy, I just had to create a static object of type AutoMapper, and configure it to use the mapping profile, which was a class that contained all the models that needed to be mapped.
The following is a way of using AutoMapper:
Using the map: