Base solution for your next web application
Open Closed

Soft deleted entity still loaded with GetAll #11211


User avatar
0
daws created

.net core, angular, aspnetzero 8.8

We have a full audited entity :

[Audited]
public class MyEntity : FullAuditedEntity<short>, IExtendableObject, IPassivable, IValidityRange

When we load it like this in a manager :

[UnitOfWork]
public async Task<List<MyEntity>> GetAllActiveAsync(Expression<Func<MyEntity, bool>> predicate)
{
    return await _MyEntityRepository.GetAll().Where(x => x.IsActive).Where(predicate).ToListAsync();
}

Soft deleted entities are also loaded whereas they should not. We did not override GetAll in the repository.

We currently have a workaround but it's not clean :

public class MyDbContext : AbpZeroDbContext<Tenant, Role, User, MyDbContext>, IAbpPersistedGrantDbContext
{
    ...
    modelBuilder.Entity<MyEntity>().HasQueryFilter(p =>
        !p.IsDeleted
    );
}

How can we solve this ?


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @daws

    Sorry for my late reply. Could you share your Abp version as well ? We will try to reproduce it.

  • User Avatar
    0
    daws created

    hi @ismcagdas,

    Abp version is 6.3.1 (aspnetzero 8.8). We plan to migrate to anz 13.3 in september.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi **@daws **

    I couldn't reproduce it on my project. Could you send an example project to [email protected]

  • User Avatar
    0
    daws created

    Hi there, since i have no time to produce a sample project, i will continue with my workaround.

    thanks