Linq中的多个联接 [英] Multiple joins in linq

查看:114
本文介绍了Linq中的多个联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚了解了asp.net的工作方式,我试图编写一个具有多个联接的linq语句,但是我似乎没有使它工作.

I just learned how the work with asp.net and I am trying to write a linq-statement with multiple join, but I dont seem to make it work.

我有4张桌子:

  • 竞争(其中包含多个回合)
  • 圆形(有多个条目)
  • 参赛作品(可以多次出现)
  • RoundEntry(包含Round和Entry的主键,将它们组合在一起)

我要输入页面Competition.aspx,我想在不同回合中显示输入的条目.

I want to you enter the page competition.aspx I want to display the entered entries within the different rounds.

有人可以帮我做这个陈述,以及关于如何建立我的页面的建议.

Can someone help me with the statement, as well a suggestion how to build up my page.

推荐答案

假定您具有名为db的数据上下文,并且表具有名为Id的键.

Assume you have data context named db and tables have keys named Id.

var entries = from e in db.Entry
              join re in db.RoundEntry on e.Id equals re.EntryId
              join r in db.Round on re.RoundId equals r.Id
              select e;

这篇关于Linq中的多个联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆