执行以下查询操作后,this.personList的Attended字段会被全部修改为true,但去掉结尾的ToList()就不会了。var disease = (from p in this.personList
               where p.Attended == true
               join c in this.conclusionList.Distinct(new EqualityDiseaseName()).ToList()
               on p.PatientID equals c.PatientID
               select new
                  {
                      PatientID = p.PatientID,
                      Sex = p.Sex,
                      Age = p.Age,
                      DiseaseKind = c.ConclusionType,
                      DiseaseName = c.ConclusionName,
                      Depiction = c.ConclusionDepiction,
                      Suggestion = c.ConclusionAdvice
                   }).ToList();请高手解答下这是为什么,谢谢了!

解决方案 »

  1.   

    你贴全了吧。Query不会修改源值的。
      

  2.   

    from p in this.personList
      where p.Attended == true不会修改源数据的值的
    是你自己过滤掉了Attended==false的数据了
      

  3.   

    from p in this.personList
      where p.Attended == true不会修改源数据的值的
    是你自己过滤掉了Attended==false的数据了
      

  4.   

    .ToList()只会立即执行查询  将结果加载到内存中而已
      

  5.   

    你把SubmitChanges() 或者 SaveChanges() 的代码都找出来看看。没有提交也不可能修改你直接查看数据库呢?你程序使用的数据库和你查看的数据库一致吗?
      

  6.   

    找到原因了,大意了,把
    where p.Attended == true
    写成了
    where p.Attended = true