0
我想連接兩個字段並列出數據庫類的所有項目。使用Entity framework
和ASP.Net MVC
的列表方法,爲什麼我不能這樣做?實體框架5:連接兩個字段
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.FName + " " + item.Lname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CustomerID }) |
@Html.ActionLink("Accounts", "Accounts", new { id=item.CustomerID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CustomerID })
</td>
</tr>
}
我得到以下錯誤:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'Customer' does not contain a definition for 'Lname' and no extension method 'Lname' accepting a first argument of type 'Customer' could be found (are you missing a using directive or an assembly reference?)
如何解決此問題?