所以我试图将DTO映射回业务层对象,我使用了多对多,这是我第一次遇到这样的映射
我的游戏室上课
public class GameRoomDto
public int Id { get; set; }
public string Name { get; set; } = null!;
public ICollection<GameRoomPlayer> Players { get; set; } = null!;
我的多对多课程
public class GameRoomPlayer
public int GameRoomId { get; set; }
public GameRoomDto GameRoom { get; set; } = null!;
public int PlayerId { get; set; }
public PlayerDto Player { get; set; } = null!;
我的PlayerTo课程
public class PlayerDto
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Email { get; set; } = null!;
public ICollection<GameRoomPlayer> GameRooms { get; set; } = null!;
我要映射到的类
public class GameRoom
public int Id { get; init; }
public string Name { get; set; } = null!;
public List<Player> Players { get; set; } = null!;
因此,我使用了多对多的方法,使EF的连接更具逻辑性,现在很难理解如何使用automapper准确地映射这一点。。。
有什么建议吗?