【AutoMapper简介】

【简介】

项目地址:https://github.com/AutoMapper/AutoMapper

帮助文档:https://github.com/AutoMapper/AutoMapper/wiki

新手入门:https://github.com/AutoMapper/AutoMapper/wiki/Getting-started

AutoMapper是一个.NET的对象映射工具,AutoMapper可以将复杂的对象转换为DTO(Data Transfer Object),或者简单的对象,以方便数据的序列化以及传输。

【支持的平台】

  • .NET 4 and higher
  • Silverlight 4 and higher
  • Windows Phone 7.5 and higher
  • .NET for Windows Store apps (WinRT)

【为什么要使用AutoMapper?】

Mapping code is boring. Testing mapping code is even more boring. AutoMapper provides simple configuration of types, as well as simple testing of mappings. The real question may be "why use object-object mapping?" Mapping can occur in many places in an application, but mostly in the boundaries between layers, such as between the UI/Domain layers, or Service/Domain layers. Concerns of one layer often conflict with concerns in another, so object-object mapping leads to segregated models, where concerns for each layer can affect only types in that layer.

层与层之间如果使用同一实体,可能会因为不同的需求而产生冲突;为了避免冲突,可以在各个需要实体的层映射产生需要的实体。

原文地址:https://www.cnblogs.com/fb-boy/p/3480464.html