Entity structure execution

I am new to entity framework and am wondering when data is actually taken from a database. If I, for example, does:

from order in orderQuery where order select car;

      

is it data that is then fetched from the database, or is it the first time I manipulate it like the code below?

(from order in orderQuery where order select car).ToList(); 

      

0


a source to share


2 answers


LINQ queries have a property called execution latency. This separates the building and execution of the query into two separate parts. The first example you provided only defines a query and therefore will not result in any execution. The second, however, will force the request to complete



+1


a source


The entity structure works with lazy load, database data is requested only when the data is really needed.



Thus, only the second example will execute the request.

+1


a source







All Articles