首页 新闻 赞助 找找看

MVC强类型点不出来,CS1061: “System.Collections.Generic.IEnumerable<ERP.Models.StoreHouse>”不包含“storeName”的定义,并且找不到可接受类型

0
悬赏园豆:5 [待解决问题]

CS1061: “System.Collections.Generic.IEnumerable<ERP.Models.StoreHouse>”不包含“storeName”的定义,并且找不到可接受类型为“System.Collections.Generic.IEnumerable<ERP.Models.StoreHouse>”的第一个参数的扩展方法“storeName”(是否缺少 using 指令或程序集引用?)

控制器

public ActionResult KF()
{
IEnumerable<StoreHouse> p = db.StoreHouse.ToList();
return View(p);
}

Model:


namespace ERP.Models
{
using System;
using System.Collections.Generic;

public partial class StoreHouse
{
public StoreHouse()
{
this.StoreArea = new HashSet<StoreArea>();
}

public int storeId { get; set; }
public string storeName { get; set; }
public string storeDesc { get; set; }

public virtual ICollection<StoreArea> StoreArea { get; set; }
}
}

视图:就是红色区域报错,求大神指教

@{
Layout = null;
}
@model IEnumerable<ERP.Models.StoreHouse>
<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>KF</title>
<link href="~/Content/easyui/themes/default/easyui.css" rel="stylesheet" />
<link href="~/Content/easyui/themes/icon.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Content/easyui/jquery.easyui.min.js"></script>
<script src="~/Content/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(function () {

});
</script>
<style type="text/css">
#panel_top table tr {
height: 50px;
line-height: 50px;
}
</style>
</head>
<body>
<div id="kf">
<div style="margin-left: 50px; margin-top: 15px;">
<h3>库房管理</h3>
<div id="panel_top" class="easyui-panel" title="库房添加/修改"
style="width: 1000px; height: 220px; padding: 10px; background: #fafafa;"
data-options="collapsible:true">
@using (Html.BeginForm())
{
<table>
<tr>
<td>库房名称:</td>
<td colspan="2">
@Html.EditorFor(m => m.storeName)
<input id="Submit1" type="submit" value="新添" style="margin-left: 10px; width: 80px;" />
</td>
</tr>
<tr>
<td>描述:</td>
<td>
@Html.TextAreaFor(m => m.storeDesc)</td>

</tr>
</table>
}
</div>
</div>
<div style="margin-left: 50px; margin-top: 15px;">
<table id="tb" class="easyui-panel" title="库房列表"
style="width: 1000px; height: 220px; padding: 10px; background: #fafafa;">
<tr>
<th>名称</th>
<th>描述</th>
<th>编辑</th>
<th>删除</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(m => m.storeName)</td>
<td>@Html.DisplayFor(m => m.storeDesc)</td>
<td>@Html.ActionLink("编辑", "edit", new { id = item.id })</td>
<td>@Html.ActionLink("删除", "edit", new { id = item.id })</td>
</tr>
}
</table>
</div>
</div>
</body>
</html>

amin_cat的主页 amin_cat | 初学一级 | 园豆:197
提问于:2017-05-25 00:12
< >
分享
所有回答(3)
0

直接用item 对象item.storeName  试试

筱浬 | 园豆:601 (小虾三级) | 2017-05-25 09:01

直接报错了

CS0411: 无法从用法中推理出方法“System.Web.Mvc.Html.DisplayExtensions.DisplayFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>)”的类型参数。请尝试显式指定类型参数。

支持(0) 反对(0) amin_cat | 园豆:197 (初学一级) | 2017-05-25 11:45
0

@Html.DisplayFor(item.storeName)

吴瑞祥 | 园豆:29449 (高人七级) | 2017-05-25 09:51

直接报错了。。。

CS0411: 无法从用法中推理出方法“System.Web.Mvc.Html.DisplayExtensions.DisplayFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>)”的类型参数。请尝试显式指定类型参数。

伤心

支持(0) 反对(0) amin_cat | 园豆:197 (初学一级) | 2017-05-25 11:45
0

关掉编译器,重新打开,再新建个类似的页面试试

龙行天涯 | 园豆:1794 (小虾三级) | 2017-05-25 14:11

还是一样的额。

支持(0) 反对(0) amin_cat | 园豆:197 (初学一级) | 2017-05-25 15:05

@amin_cat: 代码没错,换个实体类试试,是不是你这个实体类有问题。

支持(0) 反对(0) 龙行天涯 | 园豆:1794 (小虾三级) | 2017-05-25 15:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册