我正在使用自动映射器,我想将CaptionDto的一个枚举映射到Captions。
public class CaptionDto
{
public System.Guid Id { get; set; }
public System.Guid ItemId { get; set; }
public long StartTimeMilisec { get; set; }
public long EndTimeMilisec { get; set; }
public string FirstLine { get; set; }
public string SecondLine { get; set; }
}
public class Caption
{
public System.Guid Id { get; set; }
public System.Guid OrderId { get; set; }
public long StartTimeMilisec { get; set; }
public long EndTimeMilisec { get; set; }
public string FirstLine { get; set; }
public string SecondLine { get; set; }
}
问题是,在数据库(2个不同的表)中,OrderId与ItemId之间存在多对一的关系。 将CaptionDto映射到集合时,我需要选择匹配的OrderId并为每个映射的Caption设置它。 输入集合中的ItemId可能带有字幕,并且我想避免为同一ItemId多次选择OrderId。