1

DisplayForModel および EditorForModel ヘルパー関数を使用してビューをレンダリングしようとしています。最初のステップとして、組織の列挙可能なリストを作成するリスト コントローラーを用意しました。

私はこの SO questionからの Darian の回答に従い、以下のようにしました。

中 - list.cshtml

@using PartyBiz.Models.Objects
@model IEnumerable<Organization>

@Html.DisplayFor( model => model.Organizations )

中 - Organization.cshtml

@model PartyBiz.Models.Objects.Organization

<div>@Model.Caption </div>

<div>@Model.Description  </div>

<div>@Model.NameInUse  </div>

私のモデルには以下のプロパティがあります

public IEnumerable<Organization> Organizations { get; set; }

コントローラ リスト アクション

public ViewResult List(OrganizationQuery qry = null)
{
    return View(OrganizationRepo.All() as IEnumerable<Organization>);
}

ただし、コンパイルエラーが発生します:

コンパイラ エラー メッセージ: CS1061: 'System.Collections.Generic.IEnumerable' には 'Organizations' の定義が含まれておらず、タイプ 'System.Collections.Generic.IEnumerable' の最初の引数を受け入れる拡張メソッド 'Organizations' が見つかりませんでした ( using ディレクティブまたはアセンブリ参照がありませんか?)

私がここで間違っていることを教えてください。

4

2 に答える 2