Best Practices for mapping one object to another

前端 未结 4 889
后悔当初
后悔当初 2020-12-02 15:40

My question is, what is the best way I can map one object to another in the most maintainable manner. I cannot change the way the Dto object that we are getting is setup to

4条回答
  •  执笔经年
    2020-12-02 16:18

    Efran Cobisi's suggestion of using an Auto Mapper is a good one. I have used Auto Mapper for a while and it worked well, until I found the much faster alternative, Mapster.

    Given a large list or IEnumerable, Mapster outperforms Auto Mapper. I found a benchmark somewhere that showed Mapster being 6 times as fast, but I could not find it again. You could look it up and then, if it is suits you, use Mapster.

提交回复
热议问题