public void Update(TEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } try { _context.Set <TEntity>().Attach(entity); } catch (Exception e) { _context.Entry(entity).State = EntityState.Detached; _context.Set <TEntity>().Attach(entity); } _context.Entry(entity).State = EntityState.Modified; }
public Repository(TESTContext context) { _context = context; _entities = context.Set <TEntity>(); }