MapFrom
is used to connect properties - you want ResolveUsing
:
Mapper.CreateMap<Domain.Code.CodeSection, EF.Code.CodeSection>()
.ForMember(dest => dest.Parent, opt => opt.ResolveUsing(src => null));
Question
This is what I have
Mapper.CreateMap<Domain.Code.CodeSection, EF.Code.CodeSection>().ForMember(dest => dest.Parent, opt => opt.MapFrom(src => src.Parent.Id));
This doesn't compile because src.Parent.Id
is an Int
and dest.Parent
is an object.
All I want is to set dest.Parent
to null
.
Something like Mapper.CreateMap<Domain.Code.CodeSection, EF.Code.CodeSection>().ForMember(dest => dest.Parent, opt => opt.MapFrom(src => null));
Solution
MapFrom
is used to connect properties - you want ResolveUsing
:
Mapper.CreateMap<Domain.Code.CodeSection, EF.Code.CodeSection>()
.ForMember(dest => dest.Parent, opt => opt.ResolveUsing(src => null));