Hi,
want to disable softdelete at update of a certain entity like:
using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))
{
await AddReportChilds(input, report, false);
await _reportRepository.UpdateAsync(report);
}
It's not working.
6 Answer(s)
-
0
I haven't understand why you want to disable it while updating. It's generally disabled while getting entities. Are you getting any exception or what's happening and what you expect?
Anyway, can you try to change your code like that:
using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete)) { await AddReportChilds(input, report, false); await _reportRepository.UpdateAsync(report); await UnitOfWorkManager.Current.SaveChangesAsync(); }
-
0
Hi, In the UOW there are some deletes of child objects from report. These deletes should be deleted, not soft deleted.
I should I force to delete these in stead of softdelete?
-
0
Hi,
Data filters work on selecting data. If your entity is SoftDelete, ABP always soft-deletes it and prevents actually deleting.
So, whay you can do? You can override CancelDeletionForSoftDelete method in your DbContext and prevent cancellation conditionally. Here, you can check if SoftDelete filter is enabled using this.IsFilterEnabled() extension method of EntityFramework.DynamicFilters. If it's enabled, you return from method. If not, call base method.
-
0
Hi,
Thanks - thats what I was looking for. Obvious that datafilter are there for retrieving data.
-
0
See <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/1334">https://github.com/aspnetzero/aspnet-ze ... ssues/1334</a>
Its a bug
-
0
It's not a bug, it's by design, as Volosoft has clearly pointed out.