Automapper - Bestpractice of mapping a many-to-many association into a flat object
问题 I have two entities: Employee and Team . What I want is an EmployeeForm that has the Name of the Team . How can I achieve this using AutoMapper ? My current "solution" is the following: Mapper.CreateMap<Employee, EmployeeForm>() .ForMember(dest => dest.TeamName, opt => opt.MapFrom(x => x.GetTeams().FirstOrDefault() != null ? string.Join(", ", x.GetTeams().Select(y=>y.Name)) : "n/a")); In my opinion this is bad readable. What I would like to have is a generic method where I can pass an entity,