vendredi 23 septembre 2016

c# mapping class to another class

I am interested in best design pattern on below issue. Say I have 2 classes with different number of properties. I need to map instance of source class to target class' instance. Mapping source property may not be simply as just equal. There may conditional check and etc. As simplest way would be writing method and accept source class'object as parameter. Then manipulate properties and initialize target class' object. However it is not good, as there will be duplicate code and logic. Because there are will be many type of source classes. So, I will be forced writing code fach convertion. Something comes to my mimd generic methods? Thanks for your time.

Aucun commentaire:

Enregistrer un commentaire