我对嵌套实体有疑问:
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
时,它包括People
至Department
...
但是如果我想读People
时排除ReadPerson
,而当我People
时包括ReadDepartment
怎么办?
有可能吗?