views:

71

answers:

1

I built a site using LINQ and it has started to show issues with the results it brings up.

The results brought out by the query do not reflect the data in the database, they reflect an older version of the database.

In all the places where the LINQ data context was created it was disposed off properly. The sample code used in the site looks like this

 using (DataClassesDataContext context = new DataClassesDataContext()) 
 {
     return (<query here>).Distinct().ToList();
 }
+1  A: 

Check the generated SQL at runtime when debugging, and check the results against your database...

Also check your connection strings, maybe your DataContext is connecting to another database...

CMS
No it is pointing to the same DB and I throughly verified this problem. The LINQ query running on website gives a different result and if I write my own app and run that query it gives me a different result.
Syed Sajid Nizami
I have seen this issue reported at places and it has something to do with DataContext not being disposed properly. In my case I have a using construct which should control the lifetime of this data context. Still the results are different
Syed Sajid Nizami
Also, here is another symptom. If I use iisreset, the site gets normal data for a while. Here I would like to say that there is no caching on the server of any sort.
Syed Sajid Nizami