Reputation: 121
Entity Framework does not display the last changes from the database, but after sometime it shows the updated contents. I don't any special cache on the server or on the page. Thank in advance. Jack Here is the code i use to get the list, that has problem:
var m =
from relation in ett.Article_Relations
from article in ett.Article_Articles
from content in ett.Article_Contents
where relation.MenuItemID == id
where relation.Article_Articles.ArticleID == article.ArticleID
where content.LanguageID == LanguageID
where article.ArticleID == content.Article_Articles.ArticleID
select new ArticleViewModel
{
ArticleID = article.ArticleID,
IsActive = article.IsActive,
Author = article.ArticleAuthor,
Content = content,
DateCreated = article.DateCreated
};
Upvotes: 2
Views: 568
Reputation: 172606
There is nothing wrong with the query you show, therefore I expect you are using the ObjectContext
for a longer period than intended. Are you caching an object context in the ASP.NET cache or Session? If so, you should create an ObjectContext
at least once per request. Never less.
The thing is that the Entity Framework ObjectContext
is a unit of work. It caches objects during its lifetime. This means that when you query the database for an object that is already in cache, EF will retrieve that value from the database (most of the time), but will throw away the results, and return the cached object. This could explain why you are not seeing updates.
Upvotes: 1