标签:target gate rom tree member getmenu mapper 指定字段 children
var config = new MapperConfiguration(
cfg => cfg.CreateMap<SYS_Menu, MenuTreeNode>()
.ForMember(d => d.Id, opt => opt.MapFrom(s => s.MenuID)) //指定字段一一对应
.ForMember(d => d.Title, opt => opt.MapFrom(s => s.MenuName)) //指定字段一一对应
.ForMember(d => d.LinkUrl, opt => opt.MapFrom(s => s.NavigateUrl)) //指定字段一一对应
.ForMember(d => d.Children, opt => opt.MapFrom(s => s.Children))
);//指定字段,并转化指定的格式
var mapper = config.CreateMapper();
List<SYS_Menu> target = this.GetMenuTree(currentUserId);
List<MenuTreeNode> res = mapper.Map<List<MenuTreeNode>>(target);
标签:target gate rom tree member getmenu mapper 指定字段 children
原文地址:https://www.cnblogs.com/Jiangdu/p/12085018.html