views:

122

answers:

3

I just want to confirm... LINQ-to-SQL queries never execute (hits the database) until it is enumerated, right?

Does anyone know if this is the same for LINQ-to-Entities?

Thanks!

+2  A: 

Yes, this is called Deferred Execution.

CMS
A: 

Yes, they behave the same.

The query will be executed upon the first usage of the variable.

Adrian Godong
+1  A: 

Watch this screencast: When Do LINQ to SQL Queries Execute?

Jason Irwin