|
|
|
@ -9,7 +9,6 @@ using System.ComponentModel; |
|
|
|
using System.Data; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Globalization; |
|
|
|
using System.Net; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Text; |
|
|
|
using System.Text.Encodings.Web; |
|
|
|
@ -280,20 +279,28 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<TApplication?> FindByClientIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
public virtual ValueTask<TApplication?> FindByClientIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
throw new ArgumentException(SR.GetResourceString(SR.ID0195), nameof(identifier)); |
|
|
|
} |
|
|
|
|
|
|
|
return await (from application in Applications.AsTracking() |
|
|
|
where application.ClientId == identifier |
|
|
|
select application).FirstOrDefaultAsync(cancellationToken); |
|
|
|
return GetTrackedEntity() is TApplication application ? new(application) : new(QueryAsync()); |
|
|
|
|
|
|
|
TApplication? GetTrackedEntity() => |
|
|
|
(from entry in Context.ChangeTracker.Entries<TApplication>() |
|
|
|
where string.Equals(entry.Entity.ClientId, identifier, StringComparison.Ordinal) |
|
|
|
select entry.Entity).FirstOrDefault(); |
|
|
|
|
|
|
|
Task<TApplication?> QueryAsync() => |
|
|
|
(from application in Applications.AsTracking() |
|
|
|
where application.ClientId == identifier |
|
|
|
select application).FirstOrDefaultAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<TApplication?> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
public virtual ValueTask<TApplication?> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
@ -302,9 +309,17 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor |
|
|
|
|
|
|
|
var key = ConvertIdentifierFromString(identifier); |
|
|
|
|
|
|
|
return await (from application in Applications.AsTracking() |
|
|
|
where application.Id!.Equals(key) |
|
|
|
select application).FirstOrDefaultAsync(cancellationToken); |
|
|
|
return GetTrackedEntity() is TApplication application ? new(application) : new(QueryAsync()); |
|
|
|
|
|
|
|
TApplication? GetTrackedEntity() => |
|
|
|
(from entry in Context.ChangeTracker.Entries<TApplication>() |
|
|
|
where entry.Entity.Id is TKey identifier && identifier.Equals(key) |
|
|
|
select entry.Entity).FirstOrDefault(); |
|
|
|
|
|
|
|
Task<TApplication?> QueryAsync() => |
|
|
|
(from application in Applications.AsTracking() |
|
|
|
where application.Id!.Equals(key) |
|
|
|
select application).FirstOrDefaultAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|