public async Task DeleteUserAsync(int id) { var user = await _userRepository.GetAsync(id); if (user == null) { throw new ArgumentException("User not found"); } user.IsDeleted = true; await _userRepository.SaveChangesAsync(); }
public async Task DeleteMultipleEntitiesAsync(IEnumerableThis code deletes multiple entities by iterating through the list of IDs and marking each entity as deleted using SaveChangesAsync. These examples use the EntityFrameworkCore package library for database operations, which includes the IDeletableEntityRepository interface.ids) { var entities = await _repository.GetAsync(ids); foreach (var entity in entities) { entity.IsDeleted = true; } await _repository.SaveChangesAsync(); }