private void detach_Words(Words ent) { NotifyPropertyChanging("Words"); ent.Nest = null; }
private void attach_Words(Words ent) { NotifyPropertyChanging("Words"); ent.Nest = this; }
public void AddWord(Words ent) { var exists = from t in nlDB.Words where t.WordId == ent.WordId select t; if (exists.Count() == 0) { ent.Nest = nlDB.Nests.Where(t => t.NestId == ent.NestId).FirstOrDefault(); nlDB.Words.InsertOnSubmit(ent); AllWords.Add(ent); } else { Words t = exists.FirstOrDefault(); t.AddedAtDate = ent.AddedAtDate; t.AddedBy = ent.AddedBy; t.AddedByEmail = ent.AddedByEmail; t.AddedByUrl = ent.AddedByUrl; t.CommentsCount = ent.CommentsCount; t.Derivatives = ent.Derivatives; t.Description = ent.Description; t.Ethimology = ent.Ethimology; t.Example = ent.Example; t.NestId = ent.NestId; t.WordComments = ent.WordComments; t.WordContent = ent.WordContent; t.Nest = nlDB.Nests.Where(t2 => t2.NestId == ent.NestId).FirstOrDefault(); t.RefNestId = t.Nest.Id; } nlDB.SubmitChanges(); }