Hi, I am new to the entity framework and wondered, when the data is actually taken from the database. If I e.g. does:
from order in orderQuery where order select car;
is the data then selected from the database, or is it first when I manipulate it like the code below?
(from order in orderQuery where order select car).ToList();
From stackoverflow
-
The entity framework works in lazy-load fashion, the databse is queried only when the data is actually needed.
So the query will only be executed on your second example.
-
LINQ queries have a property called delayed execution. This separates out the building and execution of a query into 2 distinct parts. The first example you gave only defines a query and hence won't cause any execution. The second however will force the query to run to completion
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.