示例类结构
class Order
{
public int Id { get; set; }
public DateTime Date { get; set; }
public List<OrderDetail> Details { get; set; }
}
class OrderDetail
{
public int Id { get; set; }
public int Qty { get; set; }
public Item Item { get; set; }
}
class Item
{
public int Id { get; set; }
public string Name { get; set; }
}
class ElectronicItem : Item
{
public MoreDetail Detail { get; set; }
}
class MoreDetail
{
public int Id { get; set; }
public string SomeData { get; set; }
}
为了用所有导航属性填充订单对象,我写了
context.Orders.Include("Details").Include("Details.Item")
我也想加载 MoreDetail 对象,因此我尝试了
context.Orders.Include("Details").Include("Details.Item.Detail")
它没有用。如何加载完整的订单对象?