I have been flattening domain objects into DTOs as shown in the example below:
public class Root
{
public string AParentProperty { get; set; }
public
2 more possible solutions:
Mapper.CreateMap()
.ForMember(s=>s.AParentProperty, o=>o.Ignore());
Mapper.CreateMap()
.ForMember(d => d.ANestedProperty, o => o.MapFrom(s => s.TheNestedClass));
An alternative approach would be the below, but it would not pass the Mapper.AssertConfigurationIsValid()
.
Mapper.CreateMap()
//.ForMember map your properties here
Mapper.CreateMap()
//.ForMember... map you properties here
.AfterMap((s, d) => Mapper.Map(s.TheNestedClass, d));