English 中文(简体)
rror: MVCApp型导航财产。 模型。 命令不是单一系统的执行。
原标题:Error: The navigation property of type MVCApp.Models.Order is not a single implementation of System.Collections.Generic.ICollection`1[T]

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>
最佳回答

投递<条码> 页: 1

问题回答

我认为,你在“StatusType”类中遗漏了以下内容:

public virtual ICollection<Order> Order {get;set;}

我称之为《财产令》,但应该以与这种关系相同的方式加以呼吁。





相关问题
Using jquery to get a partial view and updating the UI

I need to render a partial view (returned from the controller) to show some customer summary details. This will need to happen when the user clicks on a button. In the the mean time the user can ...

MVC 2 / MVC 3 / MVC 4

MVC 2 我们可以轻松地创造领域。 现在,我的问题涉及nes地区(地区内)。

Asp.Net MVC 2 - Changing the PropertyValueRequired string

Using a resx file in the App_GlobalResources directory, I ve been able to change the default message for the PropertyValueInvalid string of the model validators. But it doesn t work to translate the ...

ASP.NET MVC 3 - What features do you want to see? [closed]

I know a bunch of people that are really enjoying the improvements that ASP.NET MVC 2 made over the first release. I have just started to migrate our MVC 1 project over and so far areas has totally ...

热门标签