I have 3 model classes as follows -
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; }
}
When I fetch the details from the context like as follows -
Order order = await _dbContext.Orders.Include(x => x.OrderDetailsList).FirstOrDefault(x => x.Id == orderId);
I would like to do the early loading of the Product
for each data in OrderDetailsList
as well when I fetch the Order
, but I'm unable to achieve this.