The Refresh method is what you are looking for: Context. Refresh(RefreshMode. StoreWins, somethings).
I changed question a little. I have to call Context. Refresh(RefreshMode.
StoreWins, somethings) first and var somethings = Context.SomethingSet.ToList() to get added rows, because refresh won't add them. I just noticed in profiler that refresh goes in one query, so performance is quite good. Thanks.
– LukLed Feb 25 '10 at 3:09.
The EF data context is an implementation of the Unit of Work pattern. As such, it is NOT designed to be keept around beyond the unit of work that is being done. Once your work is done, the expectation is that your data context is discarded.
This is a fundamental design decision for both EF v1, EF v4, and LINQ to SQL. Unless you have very specific data usage patterns and copious volumes of memory, you should avoid keeping your data contexts around longer than absolutely needed to complete your unit of work. sdesmedt.wordpress.com/2009/02/18/unit-o... takacsot.freeblog.hu/Files/martinfowler/....
I knew that someone will give that answer:) Don't worry. I use one ObjectContext per request, but I have one context that is used to cache some data. It is used only for reading.
But it is good you noticed. – LukLed Feb 25 '10 at 3:11 Well, glad you are disposing of your contexts. :D I can't count anymore how often I see people trying to keep their object contexts around forever.
They are trying to solve one perceived problem (an assumed performance hit), while at the same time they create a dozen more worse problems that also hurt performance even more in the long run. I try to crush that behavior whenever I encounter it. ;P – jrista Feb 25 '10 at 3:17.
Objectcontext cache is refreshed (.refresh ObjectContext cache.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.