LiNQ to Entities, Include less

Posted by Freddy on Stack Overflow See other posts from Stack Overflow or by Freddy
Published on 2010-03-08T13:53:40Z Indexed on 2010/03/08 14:21 UTC
Read the original article Hit count: 671

Hi,

If you are making a LinQ to entities expression for ClassA where A has a relation to ClassB like this:

var temp = from p in myEntities.ClassA.Include("ClassB")
           where ...
           select p;

You will get a set of ClassA:s with the reference to ClassB loaded. The thing in my case is that I dont really need to load ALL the ClassB-references, just a few of them. But I dont want to loop through the list of ClassA:s and load them individually, i want my database operations to be fewer and bigger instead of reading small chunks here and there.

Is it possible to put some kind of restrictions on which references to include or do you have to accept this all or nothing style?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about linq-to-entities