首页 > TAG信息列表 > CreateMap

如何使用ABP的Profile类

一、ABP的Profile有什么用? Profile用来编写AutoMapper的映射规则,在Profile类构造方法中编写的规则最后会配置到AutoMapper中,实现实体到DTO的自动映射。 二、代码浅析 1.ABP模板中,应用层的Module类有一个Initialize方法,该方法中用反射找到所有继承于Profile的类,并添加到映射配

AutoMapper学习笔记

AutoMapper 基本:var config=new MapperConfiguration(cfg=>{ cfg.CreateMap<Foo,FooTo> });var mapper=config.CreateMapper();var result=mapper.Map<FooTo>(foo); 单例注册:Mapper.Initialize() Profile: Public Class MyProfile:Profile{ pu

Asp .net core中使用AutoMapper数据映射

安装nuget包 注册服务 services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); 创建映射配置文件 配置类如下 public class TouristRouteProfile : Profile { public TouristRouteProfile() { CreateMap<TouristRoute, Tour

C# AutoMapper6.1.1使用

为什么要用DTO? 1、DTO更注重数据,对领域对象进行合理封装,从而不会将领域对象的行为过分暴露给表现层 2、DTO是面向UI的需求而设计的,而领域模型是面向业务而设计的。因此DTO更适合于和表现层的交互,通过DTO我们实现了表现层与领域Model之间的解耦,因此改动领域Model不会影响UI层 3