I have a LINQ to SQL query as shown below:
var carIds = from car in _db.Cars where car.Color == 'Blue' select car.Id;
The above will be translated below in sql:
select Id from Cars where Color = 'Blue'
I read that the steps are:
- LINQ to Lambda Expression
- Label expression for expression trees
- Expression Trees for SQL Statements
- SQL statements are executed
So my questions are when and how can this be translated and implemented?
I know that phase 4 occurs at runtime when my carIds variable gets access in a foreach loop.
foreach(var carId in carIds)
What about the other steps? when do they occur? at compile time or runtime? on which line (by definition or after definition, upon access or before its receipt)?
source share