I am having employee table:
public class Employee
{
public int Id {get;set;}
public string FirstName {get;set;}
public string LastName {get;set;}
public int SupervisorId {get;set;}
}
SupervisorId is a foreign key from the same table (Employee) that points to other employee.
Then I have something like "EmployeeSupervisorDto"
public class EmployeeSupervisorDto
{
public int Id {get;set;}
public string FirstName {get;set;}
public string LastName {get;set;}
public string FullNameSupervisor {get;set;}
}
What I want to achievie is to use automapper to set FullNameSupervisor automaticly to combination of FirstName and LastName of supervisor.
Tried so far to do something like this:
cfg.CreateMap<Employee, EmployeeSupervisorDto>()
.ForMember(e => e.FullNameSupervisor, m => m.MapFrom(p => $"{p.LastName} {p.FirstName}"));
But I have no idea how to do reference to Id that points out to employee id that is supervisor of given employee.