SQL view data is not updating properly
I have two tables (Knicks and Knacks) and a view that joins the two tables (PaddyWhacks). The tables have the following fields:
Knicks.key, Knicks.data1
Knacks.fkey, Knacks.data2
So the view contains:
PaddyWhacks.key, PaddyWhacks.data1, PaddyWhacks.data2
I am using LINQ to SQL to get the full view as IQueryable and everything looks good. After that, I grab the line from the Knicks and update it:
Knick k = db.Knicks.Single(row => row.data1 == 5);
k.data1 = 6;
db.SubmitChanges();
I know the update is correct because if I execute Count () on the Knicks where data1 == 5, the result has changed (and I can look into the database and see the change). However, if I get Paddywhacks again using:
IQueryable<PaddyWhack> rows = from row in db.PaddyWhacks select row;
The corresponding value of data1 is 5.
The app is running on a webserver, and if I wait long enough and come back to try again, I see the updated value in the IQueryable view. My guess is that something is being cached and maybe LINQ won't go back to the database to get the data again. Is there a LINQ or SQL Server feature that I should be aware of in order to solve this problem?
a source to share
I am not using linqtosql, but you are correct that something is in the cache. The view is just a "macro" query, the data is data from the original tables, so it is always updated. I would try using a different function than IQueryable () or create a new connection and then run the query.
a source to share