【发布时间】:2020-04-22 16:11:58
【问题描述】:
我在下面有一个相对复杂的查询,其中包含一些嵌套的 group by 查询。问题是我不知道如何通过查询将包含添加到任何组中。有没有办法在 EF6 的子组查询中包含子属性?
return db.PatientOrders
.Include(x => x.Patient) // this has no effect
.Where(x => !x.ProcessedOn.HasValue && x.Patient.Home.PharmacyId == pharmacyID)
.GroupBy(x => x.Patient.Home)
.ToDictionary(x => x.Key, x => x
.ToList()
.GroupBy(y => y.Patient.Department)
.ToDictionary(y => y.Key, y => y
.Include(x => x.OrderLines) // this does not compile
.ToList()
.GroupBy(z => z.Patient)
.ToDictionary(z => z.Key, z => z.ToList(), new PatientEqualityComparer()), new HomeDepartmentEqualityComparer()), new HomeEqualityComparer());
【问题讨论】:
标签: c# .net entity-framework linq entity-framework-6