我试图映射这些,但我得到了
AutoMapper.AutoMapperMappingException:“缺少类型映射配置或不支持的映射。”
public class MenuItemViewModel
{
[Required]
public string Text { get; set; }
public string URL { get; set; }
public string Icon { get; set; }
public IList<MenuItemViewModel> Children { get; set; }
public MenuItemViewModel Parent { get; set; }
public int Sort { get; set; }
}
public class MenuItem
{
public Guid Id { get; set; }
public string Text { get; set; }
public string URL { get; set; }
public string Icon { get; set; }
public IList<MenuItem> Children { get; set; }
public MenuItem Parent { get; set; }
public bool onMenu { get; set; }
public int Sort { get; set; }
public IList<MenuItemPermittedRole> MenuItemPermittedRoles { get; set; }
}
Mapper.Initialize(cfg => {
cfg.CreateMap<MenuItem, MenuItemViewModel>().ReverseMap();
});
MenuItemViewModel result = Mapper.Map<MenuItemViewModel>(menuItems); ERROR HERE