Пример #1
0
        public virtual async Task <T> AddAsync(T entity)
        {
            _context.Entry(entity).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(entity);
        }
Пример #2
0
        public void Delete(TEntity entityToDelete)
        {
            if (Db.Entry(entityToDelete).State == EntityState.Detached)
            {
                DbSet.Attach(entityToDelete);
            }

            DbSet.Remove(entityToDelete);
        }
Пример #3
0
 public async Task Update(T entity)
 {
     context.Entry(entity).State = EntityState.Modified;
     await context.SaveChangesAsync();
 }
Пример #4
0
 public async Task UpdateAsync(TEntity entity)
 {
     await Task.Run(() => _context.Entry(entity).State = EntityState.Modified);
 }
Пример #5
0
 public void Update(TEntity entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     DbSet.Update(entity);
 }