首页 > 解决方案 > 实体框架核心排除 INNER JOIN

问题描述

我对嵌套实体有疑问:

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();
}

当我阅读PersonEntity Framework Core 时,它People​​包括Department...

但是,如果我想People在我阅读的情况下排除并在我的情况下ReadPerson包括在内People怎么ReadDepartment办?

可能吗 ?

标签: entity-framework-core

解决方案


推荐阅读