附加信息:无法隐式转换类型' Test.Models.Tables'到' System.Collections.IEnumerable'。存在显式转换(您是否错过了演员?)
问题出现在Model中的foreach var项目中。我该怎么解决这个问题?
控制器:
public ActionResult ABC()
{
var model = new Test.Models.Tables();
string ABC = "ABC";
model.TableA = db.TablesA.Where(d => d.IssueKey.Contains(ABC)).ToList();
model.TableB = (from d in db.TablesA.Where(d => d.IssueKey.Contains(ABC)).ToList()
join j in db.TablesB.ToList() on d.Name equals j.ID
select new TableB() { DisplayName = j.DisplayName });
return View(model);
}
型号:
namespace Test.Models
{
public class Tables: DbContext
{
public IEnumerable<TableB> TableB { get; set; }
public List<TableA> TableA { get; set; }
查看:
@using System.Linq
@{ IEnumerable<Test.TableA>TablesA = ViewData["TableA"] as IEnumerable<TableA>;
IEnumerable<Test.TableB>TablesB = ViewData
["TableB"] as IEnumerable<TableB>;
}
@foreach (var issue in Model){