I have three tables:
tblApplications
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [varchar](250) NOT NULL,
    [Level5ID] [int] NOT NULL
tblLevel5s
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Level4ID] [int] NOT NULL,
    [Name] [varchar](250) NOT NULL
tblLevel4s
   [ID] [int] IDENTITY(1,1) NOT NULL,
   [Name] [varchar](250) NOT NULL
Relations between tables are: tblApplications >=o tblLevel5s >=o tblLevel4s (application can have one Level5 and Level5 can have one Level4)
I am using Entity Framework. It generated classes:
public partial class tblApplication    
    public int ID { get; set; }
    public string Name { get; set; }
    public int Level5ID { get; set; }
    public virtual tblLevel5s tblLevel5s { get; set; }
    public virtual ICollection<tblSystemApplication> tblSystemApplications { get; set; }
}
public partial class tblSystemApplication
{
    public int ID { get; set; }
    public int ApplicationID { get; set; }
    public int SystemID { get; set; }
    public virtual tblApplication tblApplication { get; set; }
    public virtual tblSystem tblSystem { get; set; }
}
public partial class tblSystem
{    
    public int ID { get; set; }
    public string Name { get; set; }
    public virtual ICollection<tblSystemApplication> tblSystemApplications { get; set; }
}
My goal is to, using automapper, create one class which will look like:
public class ApplicationDto
    {
        public int Id { get; set; }
        public SystemDto System { get; set; }
        public string Name { get; set; }
        public Level5Dto Level5 { get; set; }
        public Level4Dto Level4 { get; set; }
        public IEnumerable<SystemAppliationDto> SystemApplications { get; set; }
    }
I am not sure if I properly designed my ApplicationDto class. Please advise if anything should be changed.
What I have so far is:
cfg.CreateMap<tblApplications, ApplicationDto>()
.ForMember(dest => dest.Level5, opt => opt.MapFrom(src => src.tblLevel5s))
Now I need to add Level4 table to the mapping. Can you please help?
-- EDIT 1
What in case I have many to many relationship? I have middle table like
tblApplications
        [ID] [int] IDENTITY(1,1) NOT NULL,
        [Name] [varchar](250) NOT NULL
tblSystems
       [ID] [int] IDENTITY(1,1) NOT NULL,
       [Name] [varchar](250) NOT NULL
tblSystemApplications
       [ID] [int] IDENTITY(1,1) NOT NULL,
       [ApplicationID] [int] NOT NULL,
       [SystemID] [int] NOT NULL
Relation is tblApplications o=< tblSystemApplications >=o tblSystems What I would like to get System in ApplicationDto view.
-- EDIT 2
Added EF generated classes and updated ApplicationDto class
 
    