當(dāng)前位置:首頁 > IT技術(shù) > 移動(dòng)平臺(tái) > 正文

AutoMapper 中 bool與string互轉(zhuǎn)(類型轉(zhuǎn)換)
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 ? "已啟用注冊(cè)" : "未啟用注冊(cè)"))
.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 == "已啟用注冊(cè)" ? true : false))
.ReverseMap();

類型間的相互轉(zhuǎn)換

?

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

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

開通會(huì)員,享受整站包年服務(wù)立即開通 >