【发布时间】:2018-12-14 13:05:51
【问题描述】:
我有两个表 Appointment 和 TaskAllocation 具有一对多的关系。现在当我得到约会时
public IEnumerable<Appointment> GetAppointments(int employeeId, DateTime date)
{
return _context.Appointment.Where(a => a.EmployeeId == employeeId &&
a.AppointmentDate == date)
.Include(a=>a.Tasks).ToList();
}
它会导致包括一项与许多任务的约会,以及一项与该约会与许多任务的约会,依此类推。
【问题讨论】:
-
我遇到了同样的问题,通过查看输出我注意到在初始调用获取数据后没有调用加载数据。
标签: entity-framework .net-core ef-fluent-api