示例#1
0
        public void Remove <TEntity>(TEntity entityToDelete) where TEntity : class
        {
            if (entityToDelete is null)
            {
                throw new ArgumentNullException(nameof(entityToDelete));
            }

            if (_context.Entry(entityToDelete).State == EntityState.Detached)
            {
                _context.Set <TEntity>().Attach(entityToDelete);
            }

            _context.Set <TEntity>().Remove(entityToDelete);
        }
示例#2
0
 public Task UpdateAsync(User user)
 {
     _context.Entry <User>(user).State = EntityState.Modified;
     return(_context.SaveChangesAsync());
 }