c# - Automapper map recursive menu tree -


this question has answer here:

i followed instructions on https://www.mikesdotnetting.com/article/255/entity-framework-recipe-hierarchical-data-management

now i'm trying map entities dtos failing.

i saw many issues releated none of them has "clean" way of mapping. started this...

createmap<menuitem, dto.menuitem>()     .formember(d => d.children, opt => opt.mapfrom(src => src))     .formember(d => d.parent, opt => opt.mapfrom(src => src.parent))     .formember(d => d.menutext, opt => opt.mapfrom(src => src.menutext))     .formember(d => d.linkurl, opt => opt.mapfrom(src => src.linkurl))     .formember(d => d.menuorder, opt => opt.mapfrom(src => src.menuorder))     .formember(d => d.parentmenuitemid, opt => opt.mapfrom(src => src.parentmenuitemid))     .formember(d => d.menuid, opt => opt.mapfrom(src => src.menuid))     .formember(d => d.menuitemid, opt => opt.mapfrom(src => src.menuitemid))     .formember(d => d.menu, opt => opt.mapfrom(src => src.menu)); 

how should mapper know parent element map to?

any appreciated.

this should work (no stack overflow). see https://github.com/automapper/automapper/wiki/5.0-upgrade-guide#circular-references. there pr pending https://github.com/automapper/automapper/pull/2233.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -