0

MVC と Entity Framework に関するヘルプを探しています。ストアド プロシージャを Entity Framework にインポートしたところ、複雑な Name_Results のコレクションが返されました。

複雑な結果を呼び出してビュー ページに関連付けるにはどうすればよいですか? 通常のテーブル インポート モデルを使用して、ページを反復処理し、モデルを次のように参照できます。

@model IEnumerable<Project.Models.ImportedTableName>

しかし、私が言うとき

@model IEnumerable<Project.Models.ComplexName_Result> 

次の行に沿ってエラーが発生します

The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Project.Models.ImportedTableName]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Project.Models.ComplexName_Result]'.

何かアドバイス?ご協力ありがとうございました。

4

1 に答える 1

0

You need to pass the correct model type to the view. Since your view is strongly typed to IEnumerable<Project.Models.ComplexName_Result> that's what you should pass to it from your controller action:

public ActionResult SomeAction()
{
    IEnumerable<Project.Models.ComplexName_Result> model = ...
    return View(model);
}
于 2013-02-08T07:35:45.917 に答える