[英]Placing Inner Join Linq Query Into View Model
Viewmodel: 视图模型:
public IEnumerable<Telephone_Search.Models.tbl_users> users;
public IEnumerable<Telephone__Search.Models.tbl_pics> images;
public IEnumerable<Telephone__Search.Models.tbl_locations> branches;
Controller: 控制器:
public ActionResult Index()
{
var users = from a in db.tbl_users
where a.userid == 6
select a;
var branchjoin = (from e in db.users
join c in db.tbl_locations on e.address equals c.location
where e.userid == 6 && e.emp_address == c.location
select c).ToArray();
return this.View(new ViewModel
{
branches = branchjoin // Error here
users = users,
});
}
How do I out c.location
into razor view within MVC? 我如何将
c.location
放入MVC的razor视图中? The most common error I get is can't do conversion from IQueryable
to System.Generic.Collection
. 我遇到的最常见错误是无法从
IQueryable
转换为System.Generic.Collection
。 The error is stated within the code. 错误在代码中说明。
用.ToList().AsQueryable()
替换.ToArray()
,这能解决问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.