且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用自动映射器忽略嵌套属性的问题

更新时间:2022-02-24 23:07:57

好吧,我已经设法自己弄清楚了.我必须在其自己的dto映射中指定嵌套属性选项.但是,请告诉我是否还有另一种更好的方法

Well I have managed to figure it out by myself. I have to specify the nested property options in its own dto mapping. However let me know if there is another better way of doing this

  Mapper.CreateMap<EntityType, EntityTypeDto>()
                .ForMember(dest => dest.Properties, opt => opt.Ignore());               
            Mapper.CreateMap<Node, NodeDto>()
                .ForMember(dest => dest.ChildNodes, opt => opt.Ignore());