|
|
|
@ -70,32 +70,5 @@ namespace Volo.Abp.Domain.Repositories |
|
|
|
await repository.HardDeleteAsync(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
public static void HardDelete<TEntity, TPrimaryKey>(this IRepository<TEntity, TPrimaryKey> repository, TEntity entity) |
|
|
|
where TEntity : class, IEntity<TPrimaryKey>, ISoftDelete |
|
|
|
{ |
|
|
|
var repo = ProxyHelper.UnProxy(repository) as IRepository<TEntity, TPrimaryKey>; |
|
|
|
if (repo != null) |
|
|
|
{ |
|
|
|
var uow = ((IUnitOfWorkManagerAccessor)repo).UnitOfWorkManager; |
|
|
|
var baseRepository = ((RepositoryBase<TEntity>)repo); |
|
|
|
|
|
|
|
var items = ((IUnitOfWorkManagerAccessor)repo).UnitOfWorkManager.Current.Items; |
|
|
|
var hardDeleteEntities = items.GetOrAdd(UnitOfWorkExtensionDataTypes.HardDelete, () => new HashSet<string>()) as HashSet<string>; |
|
|
|
|
|
|
|
var hardDeleteKey = EntityHelper.GetHardDeleteKey(entity, baseRepository.CurrentTenant?.Id?.ToString()); |
|
|
|
hardDeleteEntities.Add(hardDeleteKey); |
|
|
|
|
|
|
|
Task.FromResult(repo.DeleteAsync(entity)); |
|
|
|
} |
|
|
|
} |
|
|
|
public static void HardDelete<TEntity, TPrimaryKey>(this IRepository<TEntity, TPrimaryKey> repository, Expression<Func<TEntity, bool>> predicate) |
|
|
|
where TEntity : class, IEntity<TPrimaryKey>, ISoftDelete |
|
|
|
{ |
|
|
|
foreach (var entity in repository.Where(predicate).ToList()) |
|
|
|
{ |
|
|
|
repository.HardDelete(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|