1

Can you clarify this please?

public static void MyMethod()
        {
          var context= new MyModel.Entities();

          //myQuery will not have result yet
           var myQuery= from a in context.MyEntity where a.id==10 select a;

          // object is populated in myqueryResults.
           var MyqueryResults= myQuery.ToList();       
        }

My Understanding of Lazy Loading is, the properties will not populated until, you need, them.

Question: There are no values coming back in myQuery, until we say .ToList(). So, Is this also a lazy loading?

1 Answer 1

1

This is not lazy-loading but lazy execution. Calling ToList twice will execute SQL two times. The result is not "cached" somewhere.

Actually, not ToList is the trigger but enumeration of the sequence. That's a difference.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.