Skip to content

Commit

Permalink
Backport the Entity Framework Core workaround to OpenIddict 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Feb 17, 2018
2 parents 8318f2d + 57676d7 commit 76cea94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,26 @@ public override async Task DeleteAsync([NotNull] TApplication application, Cance
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()
=> (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);

// 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()
=> (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);

// Remove all the authorizations associated with the application and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,15 @@ public override async Task DeleteAsync([NotNull] TAuthorization authorization, C
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()
=> (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);

// Remove all the tokens associated with the application.
Expand Down

0 comments on commit 76cea94

Please sign in to comment.