Using Studio 2008, C#, SQL Server 2005, Winforms. I've looked all over this site and can't find a situation that is the same...
I have data1 window filled from a LINQ to SQL connection. I click a button to open data2 window and edit data in there. When I close data2 window, I need to refresh the data in data1 window. So I call the SQL Server with a query through LINQ. I'm not getting back the new data I just saved from data2 window. I'm getting the old data back that was already there. Any ideas why? I verified that the data was saved in the SQL database and it is there.
Now if I close data1 window and reopen it, the correct data is there. But why when I requery the database right after closing data2 window is the data in data1 window not updating?
Code:
IEnumerable<tblConstructionRevision> newRev1 = (from y in DDBML.tblConstructionRevisions orderby y.RevDate descending, y.RevNo descending where y.DrawID == drawID select y);
It doesn't matter if I get back FirstOrDefault or the list. I can't return it to a List<> because I need the entire dataset.
It's cached, check this - http://blogs.msdn.com/b/dinesh.kulkarni/archive/2008/07/01/linq-to-sql-tips-9-understanding-datacontext-s-internal-caching.aspx
You need to use Refresh method of your data context to invalidate the cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With