【发布时间】:2018-04-21 00:18:57
【问题描述】:
我有这个问题:
IQueryable<Comment> comments = _commentRepo.Comments
.Include(c => c.CommentStaff)
.ThenInclude(c => c.StaffOffices)
.Where(c => c.CommentAuditId == auditId)
.OrderByDescending(c => c.CommentDate).Take(3);
StaffOffices 是一个多对多桥查找 POCO,如下所示:
[Table("staff_office")]
public class StaffOffice
{
[Column("staff_office_staff_id")]
public short ID { get; set; }
public Staff Staff { get; set; }
[Column("staff_office_office_id")]
public short OfficeID { get; set; }
public Office Office { get; set; }
}
我需要通过此查询填充 Office 对象。
所以我正在尝试这个:
如您所见,在 Intellisense 中,Office 并没有出现在 StaffOffices 中的 ThenInclude 中。
我怎样才能让它工作? 这是否需要在 AppContext 模型中使用 fluent API 定义?
【问题讨论】: