Which is the best approach? AutoMapper against implicit (C# Reference)

后端 未结 4 1456
臣服心动
臣服心动 2021-01-12 23:11

Automapper is a way to match types, ideally when you want to map a model and its viewmodel. But is this not the same approach that we can make with implicit in C#? (

4条回答
  •  囚心锁ツ
    2021-01-12 23:24

    AutoMapper uses reflection to map properties (slight performance overhead), allows advanced custom rules for mapping and requires 1 line of code in basic (common?) scenarios.

    Implicit operators require you to specify each property, are prone to errors (adding a new property but not adding it to the operator), are more difficult to setup for multiple types, create lots of useless code and even in the most basic setup you still have N lines of code where N is the amount of properties.

    I think it speaks for itself.

提交回复
热议问题