Milad Rashidi
Milad Rashidi

Reputation: 1376

Entity Framework query - loading data optimization

I'm using FirstOrDefault or First command in a query for retrieving data of an entity which has relation with other entities in my database.

My question is: do the FirstOrDefault or First command over a collection load all data of other entities associated with this entity into memory?

Upvotes: 0

Views: 548

Answers (1)

Paweł Górszczak
Paweł Górszczak

Reputation: 574

Look here

http://www.entityframeworktutorial.net/EntityFramework4.3/lazy-loading-with-dbcontext.aspx

The default behaviour of entity is lazy loading, so it won't load data until you ask for them.

Upvotes: 1

Related Questions