내 사용자로부터 합리적으로 자주 오류 보고서를지고있어 변경되지 행, 일반적인 일입니다 LINQ의 충돌이 - 발견 또는
Error Message: Row not found or changed.
Stack Trace:
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Controls_Article_ArticleViewer.LoadArticle()
at ViewTutorial.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
가 (필요한 경우 좀 더 세부 사항을 제공 할 수 있습니다). 이 기능
LoadArticle()
에서 유일하게 직접 LINQ 코드는 다음과 같습니다
using (MainContext db = new MainContext())
{
var q = (
from A in db.tblArticles
where A.ID == this.ArticleID && A.IsDeleted == false
select A
).SingleOrDefault();
if (q == null)
{
Server.Transfer("~/404.aspx");
Context.Response.End();
}
else
{
// Cache expired for HTML generation
if (q.HTMLLastGenerated.AddSeconds(Settings.ArticleRegenHTMLCacheSecs) < DateTime.Now)
{
q.Body = ArticlesCommon.Markdown(q.MarkupBody);
q.HTMLLastGenerated = DateTime.Now;
}
q.Views++;
q.LastView = DateTime.Now;
db.SubmitChanges();
// Set passbakcs
this.AuthorID = q.AuthorID;
this.Anchor = q.Anchor;
this.SectionID = q.SectionID;
this.Views = q.Views;
this.DatePublished = q.Date;
ArticleAnchor = q.Anchor;
ArticleAuthorID = q.AuthorID;
// Get the latest edit
ArticleEdit LatestEdit = ArticleEditCommon.GetLatestEdit(this.ArticleID);
// An edit exists!
if (LatestEdit.ID != 0)
{
this.Description = LatestEdit.Description;
this.ArticleTitle = LatestEdit.Title;
ArticleBody.Text = LatestEdit.Body;
ArticleH1.Text = ArticleTitle;
}
// No edits
else
{
this.Description = q.Description;
this.ArticleTitle = q.Title;
ArticleBody.Text = q.Body;
ArticleH1.Text = ArticleTitle;
}
// Get toal comments
TotalComments = (from C in db.tblComments where C.IsDeleted == false && C.Anchor == ArticleAnchor select new { C.ID }).Count();
// Get author details
var qq = (from A in db.tblForumAuthors where A.Author_ID == ArticleAuthorID select new { A.Username }).Single();
AuthorUsername = qq.Username;
}
}
이 LINQ를 실행하는 방법을 참조 LoadArticle
다른 기능을 할 수 있지만 위의 코드를 원인 그래서 나는, 스택 트레이스가 다르게 나올 것이라고 추측하고있다 .
이 문제의 원인은 무엇입니까? 데이터 충돌? 이 종류의 오류는 일반적으로 어떻게 해결됩니까?
어떤 아이디어가 발생합니까?
동시 업데이트가이 문제를 트리거 할 수 있습니다. 거기에 어떤 위험이 있습니까? – bzlm
@Bzlm, 예, 그렇습니다. 'LastViewed'필드가 고통을 겪을 수 있습니다.이 사이트를 처리하기 위해 어떤 것도 만들지 않았습니다. 이런 종류의 일이 발생할 가능성이 더 높기 때문에 Google 사이트의 색인 생성 속도가 증가 했습니까? –
그리고'ArticlesCommon.Markup (q.MarkupBody)'도 상당히 느린 것일 것입니다. 아마도 누군가 그 것을 보려고 할 때 실행되고, 이것을 해결하는 방법이 있을까요? –