Linq 查询 .net MVC 的问题
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 中的所有表演并显示运行2
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());
}
The query can not distuingish between a performance in ShowA run1 and Show A run2 it just duplicates all performances ShowA run1 and Show A run2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题可能在于如何将性能加入到运行/生产中,
而无需像
on g.runId equals l.runId
这样的东西,那么您将获得所有生产/运行的所有性能。I think the problem might be how you join Performance to Run/Production
without something like the
on g.runId equals l.runId
then you will get all the performances for all the productions/runs.