Browse Source

Backport the Entity Framework Core workaround to OpenIddict 1.x

pull/570/head 1.0.0-rc2
Kévin Chalet 8 years ago
parent
commit
76cea9482a
  1. 16
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs
  2. 8
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs

16
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs

@ -161,14 +161,26 @@ namespace OpenIddict.EntityFrameworkCore
throw new ArgumentNullException(nameof(application)); throw new ArgumentNullException(nameof(application));
} }
// Note: due to a bug in Entity Framework Core's query visitor, the authorizations can't be
// filtered using authorization.Application.Id.Equals(key). To work around this issue,
// this local method uses an explicit join before applying the equality check.
// See https://github.com/openiddict/openiddict-core/issues/499 for more information.
Task<List<TAuthorization>> ListAuthorizationsAsync() Task<List<TAuthorization>> ListAuthorizationsAsync()
=> (from authorization in Authorizations.Include(authorization => authorization.Tokens) => (from authorization in Authorizations.Include(authorization => authorization.Tokens)
where authorization.Application.Id.Equals(application.Id) join element in Applications on authorization.Application.Id equals element.Id
where element.Id.Equals(application.Id)
select authorization).ToListAsync(cancellationToken); select authorization).ToListAsync(cancellationToken);
// Note: due to a bug in Entity Framework Core's query visitor, the tokens can't be
// filtered using token.Application.Id.Equals(key). To work around this issue,
// this local method uses an explicit join before applying the equality check.
// See https://github.com/openiddict/openiddict-core/issues/499 for more information.
Task<List<TToken>> ListTokensAsync() Task<List<TToken>> ListTokensAsync()
=> (from token in Tokens => (from token in Tokens
where token.Application.Id.Equals(application.Id) join element in Applications on token.Application.Id equals element.Id
where element.Id.Equals(application.Id)
select token).ToListAsync(cancellationToken); select token).ToListAsync(cancellationToken);
// Remove all the authorizations associated with the application and // Remove all the authorizations associated with the application and

8
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs

@ -161,9 +161,15 @@ namespace OpenIddict.EntityFrameworkCore
throw new ArgumentNullException(nameof(authorization)); throw new ArgumentNullException(nameof(authorization));
} }
// Note: due to a bug in Entity Framework Core's query visitor, the tokens can't be
// filtered using token.Application.Id.Equals(key). To work around this issue,
// this local method uses an explicit join before applying the equality check.
// See https://github.com/openiddict/openiddict-core/issues/499 for more information.
Task<List<TToken>> ListTokensAsync() Task<List<TToken>> ListTokensAsync()
=> (from token in Tokens => (from token in Tokens
where token.Authorization.Id.Equals(authorization.Id) join element in Authorizations on token.Authorization.Id equals element.Id
where element.Id.Equals(authorization.Id)
select token).ToListAsync(cancellationToken); select token).ToListAsync(cancellationToken);
// Remove all the tokens associated with the application. // Remove all the tokens associated with the application.

Loading…
Cancel
Save