メンバーシップ/ロール テーブルから「ロール」のリストを表示しようとしています
私のコントローラーは:
' GET: /Admin/Index
Function Index() As ActionResult
Dim model = New AdminRoles()
model.Roles = Roles.GetAllRoles()
Return View(model)
End Function
私のモデルは次のとおりです。
Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel
Public Class AdminRoles
Public Property Roles() As String()
End Class
Public Class AdminRolesDBContext
Inherits DbContext
Public Property AdminRole() As DbSet(Of AdminRoles)
End Class
私の見解は次のとおりです。
@ModelType IEnumerable(Of MPConversion.AdminRoles)
@Code
ViewData("Title") = "Index"
End Code
<h2>Index</h2>
<p> @Html.ActionLink("Create New", "Create")</p>
<table><tr><th>Role</th><th></th></tr>
@For Each item In Model
Dim currentItem = item
@<tr>
<td>currentitem.Roles</td>
<td>
@*@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.PrimaryKey}) |
@Html.ActionLink("Details", "Details", New With {.id = currentItem.PrimaryKey}) |
@Html.ActionLink("Delete", "Delete", New With {.id = currentItem.PrimaryKey})*@
</td>
</tr>
Next
</table>
ただし、エラーが発生します:
ディクショナリに渡されたモデル アイテムのタイプは 'MPConversion.AdminRoles' ですが、このディクショナリにはタイプ 'System.Collections.Generic.IEnumerable`1[MPConversion.AdminRoles]' のモデル アイテムが必要です。
誰かが私が間違っているところを見ることができますか?