Q:我如何能够在我的命令物体内(在我的控制器和raz眼中......使用mvc3/ef4.1/.edmx)查阅以下命令: 下面的法典列出了标题中指明的错误。
- 《主计长法》(主编)
public ViewResult Details(int id)
{
Order o = db.Orders.Find(id);
OrderStatusType os = o.OrderStatusType; // <= This is throwing!
return View(o);
}
-- 模式:
public class Order
{
public int OrderId { get; set; }
public int Desc { get; set; }
public int OrderStatusTypeId { get; set; }
public virtual OrderStatusType OrderStatusType { get; set; } // Order contains an OrderSTatusType
}
public class OrderStatusType
{
public int OrderStatusTypeId { get; set; }
public int Name { get; set; }
}
www.un.org/spanish/ga/president
<div class="display-field">
@Model.OrderStatusType.Name @* This throws the same error as well *@
</div>