views:

54

answers:

1

Hi There

I am pretty new to LINQ and having a issue with what seems to be irregular content caching. The website in question has 6 content areas of different subjects now on the odd occasion the content just blanks out to nothing or has the same content for all 6 areas. It will clear up this issue by itself over time or the only other way to fix it is to recycle the app pool :(

Have tried using

DBLocal.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, ret)

but this caused similar problems.

Has anyone else come across this problem as I cannot seem to find anything about it online

Thanks Clinton

ADDED CODE:

Dim discussionDetails As Model.Discussion = Services.Discussion.getById(discussionId)


Public Function getById(ByVal discussionId As Integer) As Model.Discussion
Dim _discussion As Model.Discussion = DBLocal.Discussions.SingleOrDefault(Function(p) p.DiscussionId.Equals(discussionId))
Return _discussion
End Function
A: 

You haven't shown us the lifecycle of the DBLocal instance. It should be per-request at longest, and per-unitofwork ideally.

You haven't shown us the code that assigns the discussion to a content area, nor the code that calls this method (how frequently is it called and where does that code get Ids from?)

Consider these cases.

  • SingleOrDefault returns null, if there is no matching instance.
  • SingleOrDefault throws if there is more than one matching instance.
David B
The Id is return from the URL using "Request.QueryString" which triggers a function called updatepage(id).Then discussionDetails is defined as in the code above and then it replaces some HTML Keywords on the page like so : strHTML = strHTML.Replace("#NUMBER_OF_VIEWS", discussionDetails.NumberOfViews.ToString())
Clinton