我有两个表日期和歌曲。其中DateId是Song表的外键。传递值在Asp.net MVC3查看
- Date:
DateId
Date
- Song:
SongId
DateId
Title
下面是函数:
public ActionResult Index()
{
var song = db.TopSongs;
var model = db.Dates;
var latestDate = model.OrderByDescending(d => d.Date).FirstOrDefault();
return View(latestDate);
}
我需要证明:鉴于 Date SongId Title
。但是返回View只接受一个参数。有没有办法传递两个表数据来查看?
查看模型+1。 – DarthVader
@dbaseman - 您认为在Index()下添加5或6 ViewBag的设计是一种很好的设计?或者我应该使用一个班级? – NoviceMe
@NoviceMe肯定会更好地使用一个类......在大多数情况下最好避免使用ViewBag。 – McGarnagle