我簡單地創建了一個新的對象,它具有一對一的關係。對用戶關係的評論。當我嘗試檢索新對象時,出現錯誤無法訪問已處理的對象。我不確定發生了什麼事。感謝您的任何幫助或建議。linq to sql無法訪問處置的對象。返回一個新創建的對象
using (var db = new LinqEntityDataContext())
{
var comment = new Comment();
comment.CommentBy = GlobalVariables.User.ID;
comment.OutPutMessage = commentText.Trim();
comment.PhotoID = int.Parse(pictureID);
comment.CommentDate = DateTime.Now;
db.Comments.InsertOnSubmit(comment);
db.SubmitChanges();
return comment;
}
我這樣做,我仍然得到「無法訪問用戶屬性上的處置對象 – user516883
通過代碼調試,我看着對象Comment.User我看到'comment.User'拋出了類型' System.ObjectDisposedException」 – user516883