I hadn’t noticed this before.
If you have a stored procedure that is mapped to an entity such as "GetCustomersSince" which returns Customer entities, the command is executed when you create the query, not, like with normal queries, when the data is first needed.
In case that sentence was too convoluted…
Here is a LINQ to Entities query (the same is true for LINQ to anything and also for Object Services (context.CreateQuery))
Dim query= From c In context.Customers Select c
For Each cust in Query <– command is executed here
‘do something
End For
But when calling a function import:
dim custs= From c in context.GetCustomersSince(New Date("2008","01","01")) <–command is executed here
For Each cust in custs
‘do something
End For
Looking at the code gen for the function I can see that ObjectContext.ExecuteFunction is called.