我有3个模型类,如下所示-
class Product
{
...
}
class OrderDetails
{
...
public int ProductId { get; set; }
[ForeignKey("ProductId")]
public virtual Product Product { get; set; }
public int OrderId { get; set; }
[ForeignKey("OrderId")]
public virtual Order Order { get; set; }
}
class Order
{
...
public virtual ICollection<OrderDetails> OrderDetailsList { get; set; }
}
当我从上下文中获取详细信息时,如下所示-
Order order = await _dbContext.Orders.Include(x => x.OrderDetailsList).FirstOrDefault(x => x.Id == orderId);
当我获取Product
时,我也希望尽早为OrderDetailsList
中的每个数据加载Order
,但是我无法实现。
答案 0 :(得分:0)
这行吗?
for F in (Frame2, ):
frame = F(container, self)
self.frames[F] = frame
frame.pack(fill='both', expand=True)
答案 1 :(得分:0)
这对我来说很好,请尝试一下。
_dbContext.Orders.Include(s => s.OrderDetailsList.Select(e => e.Product));