首页 新闻 赞助 找找看

lin to sql 多表连接如果在where条件中加关联表的条件

0
悬赏园豆:100 [已关闭问题]

             //请各位大虾帮帮忙弄了我好多天了

               DataContext con = new DataContext();
                 Survey entity = null;//接收的实体对象
                 DataLoadOptions dl = new DataLoadOptions();
                    dl.LoadWith<Survey>(c => c.SurveyAnswers);//关联SurveyAnswers表
                                con.LoadOptions = dl;
                entity = (from su in con.Surveys

                           //where中我想让SurveyAnswers表的id等于传过来的id
                          where  su.ID == ID //&& SurveyAnswers.ID == AnswerID
                          select su).SingleOrDefault();

牵匹瘦驴的主页 牵匹瘦驴 | 初学一级 | 园豆:100
提问于:2010-01-18 10:06
< >
分享
其他回答(1)
0

from fist in zdc.tb_Role join jointable in zdc.tb_Login on fist.ID equals jointable.RoleID  where 。。。。。select。。。。。。

role表连接login表

可以了吧

alun | 园豆:260 (菜鸟二级) | 2010-01-19 17:38
0

在dbml文件里面就可以映射的啊,干什么那么麻烦呢。

天堂口 | 园豆:514 (小虾三级) | 2010-01-20 00:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册