Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 public void Update(TEntity obj)
 {
     db.Entry(obj).State = EntityState.Modified;
     db.SaveChanges();
 }
Esempio n. 3
0
 public bool Update(TEntity obj)
 {
     _ctx.Entry <TEntity>(obj).State = EntityState.Modified;
     _ctx.SaveChanges();
     return(true);
 }