private void detach_WordComments(WordComments ent) { NotifyPropertyChanging("WordComments"); ent.Word = null; }
private void attach_WordComments(WordComments ent) { NotifyPropertyChanging("WordComments"); ent.Word = this; }
public void AddWordComment(WordComments ent) { var exists = from t in nlDB.WordComments where t.WordCommentId == ent.WordCommentId select t; if (exists.Count() == 0) { ent.Word = nlDB.Words.Where(t => t.WordId == ent.WordId).FirstOrDefault(); nlDB.WordComments.InsertOnSubmit(ent); AllWordComments.Add(ent); } else { WordComments t = exists.FirstOrDefault(); t.Author = ent.Author; t.Comment = ent.Comment; t.CommentDate = ent.CommentDate; t.WordId = ent.WordId; ent.Word = nlDB.Words.Where(t2 => t2.WordId == ent.WordId).FirstOrDefault(); t.RefWordId = t.Word.Id; } nlDB.SubmitChanges(); }