Jan 18, 2013 at 10:15 AM
Edited Jan 18, 2013 at 10:16 AM
Effort works in the lower (logical, storage) layers of Entity Framework, so issues that is related to the upper (conceptual) layers are not likely caused by it. I checked your example code with SqlConnection and it does exactly the same as you
The problem is caused by the fact that the following expressions evaluate your enumerable method
three times. Each evaluation creates new objects.
foreach (var entity
The entities.First() expression returns a new instance of the entity that obviously was not added in the loop. You should have created the "entities" variable like this:
var entities = CreateEntityList().ToList();