What's Automapper for?

前端 未结 3 567
自闭症患者
自闭症患者 2021-02-05 08:15

What’s Automapper for?

How will it help me with my domain and controller layers (asp.net mvc)?

3条回答
  •  心在旅途
    2021-02-05 08:51

    If you have an object of one type and you want to populate the properties of an object of another type using properties from the first type, you have two choices:

    1. Manually write code to do such a mapping.
    2. Use a tool that will automatically handle this for you.

    AutoMapper is an example of 2.

    The most common use is to flatten models into a data transfer objects (or, in general, mapping across layer boundaries). What's very nice about AutoMapper is that for common scenarios you don't have to do any configuring (convention over configuration).

提交回复
热议问题