Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear object context

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?

like image 571
Max Avatar asked Dec 17 '22 21:12

Max


2 Answers

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.

like image 56
Ladislav Mrnka Avatar answered Jan 04 '23 22:01

Ladislav Mrnka


You can try to Detach each entity in the context.

like image 26
Devart Avatar answered Jan 04 '23 23:01

Devart