我正在尝试显示成员/角色表中的“角色”列表
我的控制器是:
' 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]”的模型项。
谁能看到我哪里出错了?