【发布时间】:2026-01-21 16:15:01
【问题描述】:
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 run1 和 Show A run2 中的表演,它只是复制 ShowA run1 和 Show A run2 中的所有表演
【问题讨论】:
-
能否提供数据库中数据的摘录?
-
首先,我可以建议将变量名称更改为更易于理解的名称(prod、run 和 perf 而不是 f、g 和 l)。另外,我对连接线很好奇——Production.show 是什么?
-
@HitLikeAHammer @Femaref 感谢您的回答。下面的答案就可以了。
标签: sql asp.net-mvc linq linq-to-entities