views:

67

answers:

2

If I ran several queries and ObjectContext was populated with entities how do I clear the context if I don't need those entities anymore. I know that I need to dispose the context as soon as possible, but in this case it is not possible. So is there any way that I can remove those objects from the context?

+1  A: 

There is no method for "clearing" ObjectContext. The only way to do that is to Dispose current instance of ObjectContext and start the new instance.

Ladislav Mrnka
A: 

You can try to Detach each entity in the context.

Devart
I thought about it at first, but I was hoping there's a better way. I guess there's not.
Max