To understand how execution take place consider below code:
var query = from customer in db.Customers
where customer.City == "Paris"
select customer;
Most of the people think that the query gets executed at this place but the its not right its get executed when I use query collection for
example
foreach( customer c in query)
{
}
Or
int count = (from customer in db.Customers
where customer.City == "Paris"
select customer).Count();
or to .ToList() or any other function which cause execution.
Consider another scenario
I write code like this
var query = from customer in db.Customers
where customer.City == "Paris"
select customer;
than change code to below line
query = from customer in db.Customers
where customer.City == "Mumbai"
select customer;
and than try to use query object
int count = query.Count();
Find more details[
^]