Пример #1
0
        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;
        }
Пример #2
0
 public Repository(TESTContext context)
 {
     _context  = context;
     _entities = context.Set <TEntity>();
 }