私は自分のビューでドロップダウンを設定しようとしています。どんな助けでも大歓迎です。ありがとう。LINQ to Entitiesは、Entity Data Modelプリミティブ型のキャストのみサポートしていますか?
エラー:
Unable to cast the type 'System.Int32' to type 'System.Object'.
LINQ to Entities only supports casting Entity Data Model primitive types.
コントローラー:
ViewBag.category = (from c in new IntraEntities().CategoryItems
select new SelectListItem() {Text=c.Name, Value=""+c.ID }).ToList<SelectListItem>();
ビュー:
Category:<br />@Html.DropDownList("category", (List<SelectListItem>)ViewBag.category)
Linq to enititesはconvert.Tostring()とconvert.ToDatetime()のこれらのタイプの変換をサポートしていません。 –