好的,我有两张桌子
Candidates
Id Name
1 Tejas
2 Mackroy
Experiences
Id Designation CandidateId isDeleted
1 Engineer 1 true
2 Developer 1 false
3 Tester 1 true
4 Engineer 2 false
5 Tester 2 true
模型类是:
public class Candidate
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Experience> Experiences { get; set; }
}
public class Experience
{
public int Id { get; set; }
public string Designation { get; set; }
public int CandidateId { get; set; }
public bool isDeleted { get; set; }
}
我希望获得所有候选人以及他们的资格,但只有那些isDeleted == false的候选人。
它有点像_DbContext.Candidates.Include("Qualifications").ToList();
所以它会像:
{ 1 , "光辉" , { 2, "开发者" } }, { 2, "麦克罗伊", { 4, "工程师" } }
我想知道如何通过直接使用DbContext以及使用Generic Repository来实现这一点。