如何映射已经映射到源对象的属性?我不想使用继承
public class ParentMappingProfile: Profile{
public ParentMappingProfile(){
CreateMap<App.Context.Person,Parent>()
/*this line works*/
.ForMember(dest=>dest.Children,
opt=>opt.MapFrom(src=>src.IdInversedNavigation))
/*this does not work, person remains null*/
.ForMember(dest=>dest.Person, opt=>opt.MapFrom(src=>src));
}
}
其他课程
public class PersonBase{
public int id{get;set;}
public string Name{get;set;}
}
public class PersonMappingProfile: Profile{
public PersonMappingProfile(){
CreateMap<App.Context.Person,PersonBase>()
ForMember(...);
}
}
public class Parent{
public PersonBase Person{get;set;};
public IEnumerable<PersonBase> Children{get;set;};
}