Example #1
0
        public void Delete(TEntity deletedEntity)
        {
            if (_context.Entry(deletedEntity).State == EntityState.Detached)
            {
                _context.Set <TEntity>().Attach(deletedEntity);
            }

            _context.Set <TEntity>().Remove(deletedEntity);
        }
 /// <summary>
 /// Updates a record of the database
 /// </summary>
 /// <param name="entity">Entity instance of the record to be updated</param>
 /// <returns>A task that represents the asynchronous save operation</returns>
 public async Task UpdateAsync(T entity)
 {
     _dbContext.Entry(entity).State = EntityState.Modified;
     await _dbContext.SaveChangesAsync();
 }