Working on a vb.net web form that uses LINQ-to-SQL. I have a function similar to the following:
Function GetSubjectResults(ByVal Id As Integer) As String
Dim strReturn As String = Nothing
Dim dc As New myDataContext
Dim q = From iterVar In dc.Subjects _
Where iterVar.ID = Id
If q.Count > 0 Then
If q.First Is Nothing = False Then
strReturn = q.First
The first time it runs, it gets the correct Results data (e.g. for Subject.Id = 1). However, when running it later, for a different subject (Subject.Id = 2), it returns the Results data for Subject.Id = 1 instead of 2.
I've debugged the function to confirm that the Id truly has changed to 2, so I'm pretty sure that the 2nd query is using a cache and not actually re-querying the database.
How do I force it to actually re-query the database?