title: Linq caching data values - major concurrency problem?
body: <p>Here's a little experiment I did:</p>
  
  <pre><code>MyClass obj = dataContext.GetTable&lt;MyClass&gt;().Where(x =&gt; x.ID = 1).Single();
  Console.WriteLine(obj.MyProperty); // output = "initial"
  Console.WriteLine("Waiting..."); // put a breakpoint after this line
  obj = null;
  obj = dataContext.GetTable&lt;MyClass&gt;().Where(x =&gt; x.ID = 1).Single(); // same as before, but reloaded
  Console.WriteLine(obj.MyProperty); // output still = "initial"
  obj.MyOtherProperty = "foo";
  dataContext.SubmitChanges(); // throws concurrency exception
  </code></pre>
  
  <p>When I hit the breakpoint after line 3, I go to a SQL query window and manually change the value to "updated".  Then I carry on running.  Linq does not reload my object, but re-uses the one it previously had in memory!  This is a <strong>huge</strong> problem for data concurrency!</p>
  
  <p>How do you disable this hidden cache of objects that Linq obviously is keeping in memory?</p>
  
  <p><strong>EDIT</strong> - On reflection, it is simply unthinkable that Microsoft could have left such a gaping chasm in the Linq framework.  The code above is a dumbed-down version of what I'm actually doing, and there may be little subtleties that I've missed.  In short, I'd appreciate if you'd do your own experimentation to verify that my findings above are correct.  Alternatively, there must be some kind of "secret switch" that makes Linq robust against concurrent data updates.  But what?</p>