diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs index ae5e4e18bd..3738884b5c 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs @@ -82,13 +82,20 @@ public class EfCoreOpenIddictAuthorizationRepository : EfCoreRepository() on authorization.Id equals token.AuthorizationId into authorizationTokens from authorizationToken in authorizationTokens.DefaultIfEmpty() where authorization.CreationDate < date where authorization.Status != OpenIddictConstants.Statuses.Valid || (authorization.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && authorizationToken == null) - select authorization).ExecuteDeleteAsync(cancellationToken); + select authorization.Id).ToListAsync(cancellationToken); + + await (from token in (await GetDbContextAsync()).Set() + where token.AuthorizationId != null && authorizations.Contains(token.AuthorizationId.Value) + select token) + .ExecuteDeleteAsync(GetCancellationToken(cancellationToken)); + + await (await GetDbSetAsync()).Where(x => authorizations.Contains(x.Id)).ExecuteDeleteAsync(cancellationToken); } }