2016-04-16 9 views
0

私のアプリケーションの停止にリストから変更するとは私にこのエラーメッセージを与える:IEnumerableを

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

マイコントローラー:

return PartialView("PartialViewAllRunners", db.Runners.ToList()); 

マイビュー:

@Html.Partial("~/Views/Shared/PartialViewAllRunners.cshtml", Model) 

両方ViewPartial ViewIEnumerableを持っていますので、何が問題なのですか、何を変更する必要がありますか?

+0

[This SO post](http://stackoverflow.com/questions/27378288/but-this-dictionary-requires-a-model-item-of-type-system-collections-generic-ie)では、回答。 –

+1

メッセージは自明です。 'Runner'(' IEnumerable'と 'List''は関係ありません)のコレクションを期待するビューに' GamesVM'のコレクションを渡します。 –

+0

@StephenMuecke OK、任意のパーシャルビュー私は、同じモデルでなければならないと付け加えます。 –

答えて

-1

編集 - これには、あなたのビューモデルを変更します。

@model IEnumerableを< ModelClass名>

リターンビュー(db.modelclass.ToList());