我有以下课程。
public class Candidate
{
public long Id { get; set; )
public List<JobAssigned> JobAssigned { get; set; }
}
public class JobAssigned
{
public long Id { get; set; }
public List<StageScore> StageScore { get; set; }
public List<CriteriaScore> CriteriaScore { get; set; }
public List<StageComment> StageComment { get; set; }
}
public class StageComment
{
public long Id { get; set; }
public JobAssigned JobAssigned { get; set; }
public long JobAssignedId { get; set; }
public long PipelineStageId { get; set; }
public long CandidateId { get; set; }
public long JobId { get; set; }
public string Comment { get; set; }
}
public class StageScore
{
public long Id { get; set; }
public JobAssigned JobAssigned { get; set; }
public long JobAssignedId { get; set; }
public long Rating { get; set; }
public long PipelineStageId { get; set; }
public long CandidateId { get; set; }
public long JobId { get; set; }
}
public class CriteriaScore
{
public long Id { get; set; }
public JobAssigned JobAssigned { get; set; }
public long JobAssignedId { get; set; }
public long Rating { get; set; }
public long PipelineStageCriteriaId { get; set; }
public long CandidateId { get; set; }
public long JobId { get; set; }
}
我希望一次加载所有相关表。我正在尝试跟随,
List<Candidate> candidate = _context.Candidates.
Include(f => f.JobAssigned.Select(g => g.StageScore))
.OrderBy(x => x.Id).ToList();
当我做.Select().Select()
时出现错误。如何在单个查询中获取所有集合?
答案 0 :(得分:0)
看看我写的this article,它会动态加载所有对象。
这就是您可以包括所有对象的方式。
我希望不会有圈子参考。
我在上面的url中编写的插件可以处理圆引用
List<Candidate> candidate = _context.Candidates.
Include(f => f.JobAssigned.Select(g => g.StageScore.Select(a=> a.JobAssigned))).
Include(f => f.JobAssigned.Select(g => g.CriteriaScore.Select(a=> a.JobAssigned))).
Include(f => f.JobAssigned.Select(g => g.StageComment.Select(a=> a.JobAssigned))).
OrderBy(x => x.Id).ToList();