public ActionResult Performances(string id)
{
var query =
from f in _db.Production
join g in _db.Run on f.show equals g.Production.show
join l in _db.Performance on g.startDate equals l.runStartDate
where f.show == id
select new ShowPerformance
{
Venuename = g.venue,
Showname = f.show,
RunStart = g.startDate,
RunEnd = g.endDate,
PerformanceDate = l.performanceDate,
PerformanceTime = l.performanceTime
};
return View(query.ToList());
}
查询无法区分ShowA run 1和Show A run2中的性能它只是重复所有性能ShowA run1和Show A run2
答案 0 :(得分:2)
我认为问题可能是你如何加入Performance to Run / Production
var query =
from f in _db.Production
join g in _db.Run on new {f.show, f.year} equals new {g.show, g.year}
join l in _db.Performance on new {g.venue, g.startDate} equals new {l.venue, l.runStartDate}
where f.show == id
select new ShowPerformance
{
Venuename = g.venue,
Showname = f.show,
RunStart = g.startDate,
RunEnd = g.endDate,
PerformanceDate = l.performanceDate,
PerformanceTime = l.performanceTime
};
没有on g.runId equals l.runId
之类的东西,那么你将获得所有制作/运行的所有表演。