I have a scenario in which I would like to ignore some properties of the classes defined in the base class.
I have an initial display like this
Mapper.CreateMap<Node, NodeDto>()
.Include<Place, PlaceDto>()
.Include<Asset, AssetDto>();
Then I set it up more like this to ignore one of the properties defined in the NodeDto base class
Mapper.CreateMap<Node, NodeDto>()
.ForMember(dest => dest.ChildNodes, opt => opt.Ignore());
However, when I try to match, Place to PlaceDto or Asset for AssetDto, the ChildNodes property is not ignored. So I finished doing something like this
Mapper.CreateMap<Node, NodeDto>()
.ForMember(dest => dest.ChildNodes, opt => opt.Ignore());
Mapper.CreateMap<Place, PlaceDto>()
.ForMember(dest => dest.ChildNodes, opt => opt.Ignore());
Mapper.CreateMap<Asset, AssetDto>()
.ForMember(dest => dest.ChildNodes, opt => opt.Ignore());
Since I have many child classes for NodeDto, the process described above is cumbersome and I would like to know if there is a better approach?
Thanks Nabil
source
share