How to automatically map the values between instances of two different classes if both have same properties?

后端 未结 5 1833
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 11:10

I have two classes with exactly same members (properties and fields) with same datatypes. I want to map the members from one to other in automated way. I know there are more

5条回答
  •  误落风尘
    2020-12-30 12:05

    AutoMapper is another good tool for something like this http://automapper.codeplex.com/

    You map from one object to another with something like this:

    Mapper.CreateMap();
    var myDTO = Mapper.Map(myClass);
    

提交回复
热议问题