Mapping multi level nesting object c#

Viewed 59

Model

    public class A
    {
        public IList<B> BC { get; set; } = new List<B>();
    }

    public class B
    {
        public IList<C> C { get; set; } = new List<C>();          
    }

    public class C
    {
        public string name{ get; set; }

    }

Source

public class AA
    {
        public IList<CC> BC { get; set; } = new List<B>();
    }

I need to map list cc to list c and want to display under List b like

    "A": [
    {
      "B": [
        {
          "C": name,
        }
      ],

but its showing null how do I map it, this is what I did for mapping

                CreateMap<AA, A>()
                    .ForMember(dst => dst.B, opt => opt.MapFrom(src => src.CC));
                CreateMap<CC, C>();
0 Answers
Related