public async Task UpdateAsync(TEntity entity) { var local = _context.Set <TEntity>() .Local .FirstOrDefault(entry => entry.Id == entity.Id); if (local != null) { _context.Entry(local).State = EntityState.Detached; } _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public GenericRepository(DeliveryContext context) { _context = context; _dbSet = context.Set <TEntity>(); }