Linq-to-entities - Include() method not loading

前端 未结 5 1235
既然无缘
既然无缘 2020-11-28 07:18

If I use a join, the Include() method is no longer working, eg:

from e in dc.Entities.Include(\"Properties\")
join i in dc.Items on e.ID equals i.Member.ID
w         


        
5条回答
  •  死守一世寂寞
    2020-11-28 07:58

    Try the more verbose way to do more or less the same thing obtain the same results, but with more datacalls:

    var mydata = from e in dc.Entities
                 join i in dc.Items 
                     on e.ID equals i.Member.ID 
                 where (i.Collection.ID == collectionID) 
                 select e;
    
    foreach (Entity ent in mydata) {
        if(!ent.Properties.IsLoaded) { ent.Properties.Load(); }
    }
    

    Do you still get the same (unexpected) result?

    EDIT: Changed the first sentence, as it was incorrect. Thanks for the pointer comment!

提交回复
热议问题