Skip to content

Object2ObjectMapper

gpeipman edited this page Oct 27, 2010 · 1 revision

Simple object to object mapper was product of my experiment where I tried to create mapper that is able to copy properties from one attribute to another. I had one object that came from O/R mapper and the other which was created by ASP.NET MVC binder. To avoid messing with state I was not able to replace existing object with the one that came from binder and so I decided to copy the matching properties. I found very soon way better solution to my problem but I still wanted to find out how good results I will get using different mapping methods.

There are three mapping methods

  • Dynamic Code Mapper - generates dynamic code that copies properties from one object to another
  • ReflectionBasedMapper - uses reflection to copy properties
  • LcgMapper - used Lightweight Code Generation (LCG) to copy properties

You can read more about my experiment from following sources:

There is one challence: is it possible to optimize LCG mapper to get way better performance or is there any other method that is able to beat it in speed?