I believe Thomas was suggesting to you to alter the code like this:
var obEPMAddressList = (from e
where e.PERSON_ID == obPerson.EmplID
// Update what we have.
Where Line 03 has the significant call to ToList()
method. This will execute your query immediately
and will load the instances of your entity in memory. If the number of results is reasonably small this is a very clean solution to your problem. If you expect more than 500 items in the result set you may be better without the ToList()
call since the amount of memory required will be smaller.
Normally your original code should work fine, so if it is possible can you post the whole foreach
loop code so we can check if it interrupts the enumeration somehow. One potential suspect will be a call to SaveChanges
method on the same OpenAccess context.
We are looking forward your feedback.
All the best,
the Telerik team
Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.