Are elements returned by Linq-to-Entities query streamed from the DB one at the time or are they retrieved all at once?

Posted by carewithl on Programmers See other posts from Programmers or by carewithl
Published on 2012-10-29T21:09:09Z Indexed on 2012/10/29 23:19 UTC
Read the original article Hit count: 130

Filed under:
|

Are elements returned by Linq-to-Entities query streamed from the database one at the time ( as they are requested ) or are they retrieved all at once:

    SampleContext context = new SampleContext(); // SampleContext derives from ObjectContext
    var search = context.Contacts;

    foreach (var contact in search)
    {
       Console.WriteLine(contact.ContactID); // is each Contact retrieved from the DB 
                                             // only when foreach requests it?
    }

thank you in advance

© Programmers or respective owner

Related posts about entity-framework

Related posts about LINQ