实体框架核心不包括INNER JOIN

时间:2020-06-11 11:45:42

标签: entity-framework-core

我对嵌套实体有疑问:

public class Person {
    public int Id { get; set; }    
    public Department Department { get; set; }
}
public class Department {
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public IList<Person> People { get; set; } = new List<Person>();
}

public IAsyncEnumerable<Person>? ReadPersons()
{
    return _dbContext.Persons?
            .Include(p => p.Department)
            .AsAsyncEnumerable();
}

public IAsyncEnumerable<Person>? ReadDepartments()
{
    return _dbContext.Departments?
            .Include(d => d.People)
            .AsAsyncEnumerable();
}

当我使用Entity Framework Core阅读Person时,它包括PeopleDepartment ...

但是如果我想读People时排除ReadPerson,而当我People时包括ReadDepartment怎么办?

有可能吗?

0 个答案:

没有答案