/// <summary> /// Updates a Note. /// </summary> /// <param name="note"></param> protected void UpdateNote(Note note) { ThrowIfNull(note); ValidateAndThrow(note, new NoteValidator()); Context.Notes.Attach(note); Context.SetEntityState(note, EntityState.Modified); Context.SaveChanges(); }
private void AddOrModify() { if (_comparer == null) { throw new ArgumentNullException(); } if (_updates == null) { return; } foreach (var u in _updates) { var p = _existing.SingleOrDefault(ep => _comparer(ep, u)); if (p == null) { _context.Set <T>().Add(u); } else if (_mapUpdates != null) { _mapUpdates(p, u); _context.SetEntityState(p, EntityState.Modified); } } }