Monday, November 5, 2018

A1 Repo: Explicit Mapping Using Extensions Methods Rather than Using AutoMapper

There are many reasons not to use AutoMapper in projects. I started to use AutoMapper about five years ago and the first problem that I encountered from the start gate was that using Automapper creates mapping code which is very difficult, and at times impossible to debug. Another equally distressing observation is that the code can become very complex very quickly due to formatting and conditional mappings which need to be configured in the mapper configuration.

The only one thing that I liked about AutoMapper is that I can tack away the mapping code making service operations, controller actions and methods in general more readable. Hence, in the spirit of putting away the mapping code I prefer to do explicit mapping using extension methods.

The following snippet of code maps AssetDto to AssetViewModel.



Mapping the ViewModel to a Dto would be done just in the same fashion through extension methods.


To Table of contents

No comments:

Post a Comment

A1 Repo: Simple Pagination for WCF Service Operation

It is never a good idea to paginate on the client.  This post is about a simple pagination for a WCF service operation.  For this work I nee...