当前位置:首页 > IT技术 > 移动平台 > 正文

AutoMapper 中 bool与string互转(类型转换)
2021-09-09 14:05:09

CreateMap<Application, ApplicationDto>()
.ForMember(dest => dest.Enabled, opt => opt.MapFrom(s => s.Enabled == true ? "已启用" : "未启用"))
.ForMember(dest => dest.RegisterEnabled, opt => opt.MapFrom(s => s.RegisterEnabled == true ? "已启用注册" : "未启用注册"))
.ReverseMap();
CreateMap<ApplicationDto, Application>().ForMember(dest => dest.Enabled, opt => opt.MapFrom(s => s.Enabled == "已启用" ? true : false))
.ForMember(dest => dest.RegisterEnabled, opt => opt.MapFrom(s => s.RegisterEnabled == "已启用注册" ? true : false))
.ReverseMap();

类型间的相互转换

 

来自:https://www.cnblogs.com/Anthony518/p/11038392.html

本文摘自 :https://www.cnblogs.com/

开通会员,享受整站包年服务立即开通 >