我的域模型中有很多关系:
ActiveRecord::InvalidForeignKey: Mysql2::Error: Cannot add or update a child row: a foreign key constraint fails
我需要使用AutoMapper将其分解为一对多关系,以便适合以下模型:
public class DeptNumber : TrackedObject {
public string Number { get; set; }
public string Description { get; set; }
public ICollection<DeptJobLink> DeptJobLinks { get; set; }
}
public class DeptJobLink : TrackedObject {
public long DeptNumberId { get; set; }
public DeptNumber DeptNumber { get; set; }
public long JobNumberId { get; set; }
public JobNumber JobNumber { get; set; }
}
public class JobNumber : TrackedObject {
public string Number { get; set; }
public string Description { get; set; }
public ICollection<DeptJobLink> DeptJobLinks { get; set; }
}
以下是我的自动播放器配置文件,但如果没有多对多的链接类,我似乎无法将JobNumber放入DeptNoVM中:
public class DeptNoVM : BaseVM {
public string Number { get; set; }
public string Description { get; set; }
public List<JobNoVM> Jobs { get; set; }
}
public class JobNoVM : BaseVM {
public string Number { get; set; }
public string Description { get; set; }
public DeptNoVM Department { get; set; }
public long DepartmentId { get; set; }
}
我需要DeptNumbers进入JobNoVM.Department,我需要JobNumbers进入DeptNoVM.Jobs - 我正在使用的映射导致“Value不能为null。参数名称:source”。