public async Task ApplyPatchAsync <TEntity, TDto>(TEntity entityToUpdate, TDto dto) where TEntity : class { if (dto == null) { throw new ArgumentNullException($"{nameof(dto)}", $"{nameof(dto)} cannot be null."); } var properties = dto.GetFilledProperties(); _context.Attach(entityToUpdate); foreach (var property in properties) { _context.Entry(entityToUpdate).Property(property).IsModified = true; } await _context.SaveChangesAsync(); }
public void Update(TEntity obj) { db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); }
public bool Update(TEntity obj) { _ctx.Entry <TEntity>(obj).State = EntityState.Modified; _ctx.SaveChanges(); return(true); }