猿问

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

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

               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();


偶然的你
浏览 902回答 2
2回答

烙印99

在dbml文件里面就可以映射的啊,干什么那么麻烦呢
随时随地看视频慕课网APP
我要回答