Как вы сопоставляете строго типизированное свойство, которое уже сопоставляется с исходным объектом? - PullRequest
0 голосов
/ 27 августа 2018

Как вы сопоставляете свойство, которое уже сопоставлено с исходным объектом? Я не хочу использовать наследование

    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;};
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...