dbexsionbinding需要一个带有集合ResultType的输入表达式.净MVC
本文关键字:ResultType 集合 输入 表达式 MVC 一个 dbexsionbinding | 更新日期: 2023-09-27 18:19:05
我得到这个错误dbeexpressionbinding需要一个集合ResultType的输入表达式。当涉及到使用ASP时,仍然非常绿色。. NET MVC,所以我不明白发生了什么,为什么我得到这个错误。一直在搜索论坛,但没有什么是真正有意义的。使用ADO。Net实体模型。6.
控制器readonly StatsEntity1 _db = new StatsEntity1();
public ActionResult Index()
{
var statsC = (from n in _db.WKLY_STATSTC
where n.TERM == "14"&& n.GRP=="C"
select n.TERM into w
select new { Count = w.Count() });
var statsN = (from n in _db.WKLY_STATSTC
where n.TERM == "14" && n.GRP == "N"
select n.TERM into w
select new { Count = w.Count() });
ViewBag.StatsC = statsC;
ViewBag.StatsN = statsN;
return View("Index");
}
<<p> 视图/strong> @model IEnumerable<Reports.Models.WKLY_STATSTC>
<table>
<tr>
<td>@ViewBag.StatsC</td>
<td>@ViewBag.StatsN</td>
</tr>
</table>
可能您需要的是获取查询的计数。
var statsC = (from n in _db.WKLY_STATSTC
where n.TERM == "14" &&
n.GRP == "C"
select n.TERM).Count();
var statsN = (from n in _db.WKLY_STATSTC
where n.TERM == "14" &&
n.GRP == "N"
select n.TERM).Count();
除非你真正需要的是n.Term
长度的数组。
var statsC = (from n in _db.WKLY_STATSTC
where n.TERM == "14" &&
n.GRP == "C"
select n.TERM into w
select new { Count = w.Length }).ToArray();
var statsN = (from n in _db.WKLY_STATSTC
where n.TERM == "14" &&
n.GRP == "N"
select n.TERM into w
select new { Count = w.Length }).ToArray();