I developed and entity framework (.edmx) application in 4.0 in that i got all the data of my querying table and its foreign key referenced tables data also. but when i change my project to 3.5 i am unable to get the data of foreign key referenced tables data. Please help me out...
A:
In EF4 lazy loading is included and is on by default.
No such luck in prior versions: You may need to add an .Include() to fetch the other data automatically (eager loading) or call Load() on the references to load them (manually).
If the reference table was say "Details" you would do ...
var featuredOffers = context.Hosters_FeaturedOffer.Include("Details").ToList();
See http://msdn.microsoft.com/en-us/library/bb896272.aspx
BTW: Do a search for "strongly typed Include" too - there are some extension methods people have written to remove the magic string and replace it with a compile time checked lambda expression.
Hightechrider
2010-05-03 05:51:13
Thanks Hightechrider, Can u please help me on where to add .include() in my code or how to call Load() method. below is my sample Query var result = from e in context.Hosters_FeaturedOffer select e; List<Hosters_FeaturedOffer> featuredOffers = result.ToList<Hosters_FeaturedOffer>();
Vinni
2010-05-03 05:58:39
Updated answer.
Hightechrider
2010-05-03 06:18:24
Thanks a lot Hightechrider...U saved my time..Can u also provide me some information/ links about the extension methods that u were talking about?
Vinni
2010-05-03 06:45:30
A:
thanks, I was totally sick by such a question for long time
and I used .Load() than everything is ok
but EF 3.5 really sucks
big cat
2010-10-28 14:38:06