如果我在 EF 中定义了多对多关系:
public class StudentImage
{
public int StudentId { get; set; }
public int ImageId { get; set; }
public int Order { get; set; }
public virtual Student Student { get; set; }
public virtual Image Image { get; set; }
}
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<StudentImage> Images { get; set; }
}
public class Image
{
public int Id { get; set; }
public string Filename { get; set; }
public virtual ICollection<StudentImage> Students { get; set; }
}
和 DTO 的:
public class ImageDTO
{
public int Id { get; set; }
public string Filename { get; set; }
public int Order { get; set; }
}
public class StudentIDO
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<ImageDTO> Images { get; set; }
}
如何使用 Automapper 从 Student 映射到 StudentDTO 以及从 Image 映射到 ImageDTO?