Browse Source

Update the CountAsync() API to support flowing a state parameter

dev
Kévin Chalet 7 days ago
parent
commit
01531930de
  1. 16
      src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs
  2. 16
      src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs
  3. 16
      src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs
  4. 16
      src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs
  5. 6
      src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs
  6. 6
      src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs
  7. 6
      src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs
  8. 6
      src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs
  9. 27
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  10. 27
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  11. 27
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  12. 27
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  13. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs
  14. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs
  15. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs
  16. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs
  17. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs
  18. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs
  19. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs
  20. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs
  21. 7
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs
  22. 7
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs
  23. 7
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs
  24. 7
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs

16
src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs

@ -48,6 +48,22 @@ public interface IOpenIddictApplicationManager
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary>
/// Determines the number of applications that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<object>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default);
/// <summary>
/// Creates a new application based on the specified descriptor.
/// Note: the default implementation automatically hashes the client

16
src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs

@ -46,6 +46,22 @@ public interface IOpenIddictAuthorizationManager
ValueTask<long> CountAsync<TResult>(
Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary>
/// Determines the number of authorizations that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of authorizations that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<object>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default);
/// <summary>
/// Creates a new permanent authorization based on the specified parameters.
/// </summary>

16
src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs

@ -45,6 +45,22 @@ public interface IOpenIddictScopeManager
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary>
/// Determines the number of scopes that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<object>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default);
/// <summary>
/// Creates a new scope based on the specified descriptor.
/// </summary>

16
src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs

@ -44,6 +44,22 @@ public interface IOpenIddictTokenManager
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary>
/// Determines the number of tokens that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<object>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default);
/// <summary>
/// Creates a new token based on the specified descriptor.
/// </summary>

6
src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs

@ -31,14 +31,18 @@ public interface IOpenIddictApplicationStore<TApplication> where TApplication :
/// <summary>
/// Determines the number of applications that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken);
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken);
/// <summary>
/// Creates a new application.

6
src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs

@ -28,14 +28,18 @@ public interface IOpenIddictAuthorizationStore<TAuthorization> where TAuthorizat
/// <summary>
/// Determines the number of authorizations that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of authorizations that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken);
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken);
/// <summary>
/// Creates a new authorization.

6
src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs

@ -29,14 +29,18 @@ public interface IOpenIddictScopeStore<TScope> where TScope : class
/// <summary>
/// Determines the number of scopes that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken);
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken);
/// <summary>
/// Creates a new scope.

6
src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs

@ -28,14 +28,18 @@ public interface IOpenIddictTokenStore<TToken> where TToken : class
/// <summary>
/// Determines the number of tokens that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens that match the specified query.
/// </returns>
ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken);
ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken);
/// <summary>
/// Creates a new token.

27
src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs

@ -96,7 +96,28 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, cancellationToken);
return CountAsync(static (applications, query) => query(applications), query, cancellationToken);
}
/// <summary>
/// Determines the number of applications that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, state, cancellationToken);
}
/// <summary>
@ -1845,6 +1866,10 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
ValueTask<long> IOpenIddictApplicationManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictApplicationManager.CountAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> CountAsync(query, state, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictApplicationManager.CreateAsync(OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);

27
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -92,7 +92,28 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, cancellationToken);
return CountAsync(static (authorizations, query) => query(authorizations), query, cancellationToken);
}
/// <summary>
/// Determines the number of authorizations that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of authorizations that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, state, cancellationToken);
}
/// <summary>
@ -953,6 +974,10 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
ValueTask<long> IOpenIddictAuthorizationManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictAuthorizationManager.CountAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> CountAsync(query, state, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictAuthorizationManager.CreateAsync(ClaimsIdentity identity, string subject, string client, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken)
=> await CreateAsync(identity, subject, client, type, scopes, cancellationToken);

27
src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs

@ -91,7 +91,28 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, cancellationToken);
return CountAsync(static (scopes, query) => query(scopes), query, cancellationToken);
}
/// <summary>
/// Determines the number of scopes that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, state, cancellationToken);
}
/// <summary>
@ -879,6 +900,10 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
ValueTask<long> IOpenIddictScopeManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictScopeManager.CountAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> CountAsync(query, state, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictScopeManager.CreateAsync(OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);

27
src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs

@ -92,7 +92,28 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, cancellationToken);
return CountAsync(static (tokens, query) => query(tokens), query, cancellationToken);
}
/// <summary>
/// Determines the number of tokens that match the specified query.
/// </summary>
/// <typeparam name="TState">The state type.</typeparam>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">The query to execute.</param>
/// <param name="state">The optional state.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(query);
return Store.CountAsync(query, state, cancellationToken);
}
/// <summary>
@ -1169,6 +1190,10 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
ValueTask<long> IOpenIddictTokenManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictTokenManager.CountAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> CountAsync(query, state, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictTokenManager.CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs

@ -90,13 +90,15 @@ public class OpenIddictEntityFrameworkApplicationStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TApplication>()).LongCountAsync(cancellationToken);
return await query(context.Set<TApplication>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs

@ -88,13 +88,15 @@ public class OpenIddictEntityFrameworkAuthorizationStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TAuthorization>()).LongCountAsync(cancellationToken);
return await query(context.Set<TAuthorization>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs

@ -80,13 +80,15 @@ public class OpenIddictEntityFrameworkScopeStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TScope>()).LongCountAsync(cancellationToken);
return await query(context.Set<TScope>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs

@ -88,13 +88,15 @@ public class OpenIddictEntityFrameworkTokenStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TToken>()).LongCountAsync(cancellationToken);
return await query(context.Set<TToken>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs

@ -109,13 +109,15 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TApplication>()).LongCountAsync(cancellationToken);
return await query(context.Set<TApplication>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs

@ -107,13 +107,15 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TAuthorization>()).LongCountAsync(cancellationToken);
return await query(context.Set<TAuthorization>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

@ -95,13 +95,15 @@ public class OpenIddictEntityFrameworkCoreScopeStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TScope>()).LongCountAsync(cancellationToken);
return await query(context.Set<TScope>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs

@ -107,13 +107,15 @@ public class OpenIddictEntityFrameworkCoreTokenStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var context = await Context.GetDbContextAsync(cancellationToken);
return await query(context.Set<TToken>()).LongCountAsync(cancellationToken);
return await query(context.Set<TToken>(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

7
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs

@ -67,15 +67,16 @@ public class OpenIddictMongoDbApplicationStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TApplication>(Options.CurrentValue.ApplicationsCollectionName);
return await query(collection.AsQueryable()).LongCountAsync(cancellationToken);
return await query(collection.AsQueryable(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

7
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs

@ -65,15 +65,16 @@ public class OpenIddictMongoDbAuthorizationStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
return await query(collection.AsQueryable()).LongCountAsync(cancellationToken);
return await query(collection.AsQueryable(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

7
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs

@ -66,15 +66,16 @@ public class OpenIddictMongoDbScopeStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TScope>(Options.CurrentValue.ScopesCollectionName);
return await query(collection.AsQueryable()).LongCountAsync(cancellationToken);
return await query(collection.AsQueryable(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

7
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs

@ -65,15 +65,16 @@ public class OpenIddictMongoDbTokenStore<
}
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual async ValueTask<long> CountAsync<TState, TResult>(
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(query);
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
return await query(collection.AsQueryable()).LongCountAsync(cancellationToken);
return await query(collection.AsQueryable(), state).LongCountAsync(cancellationToken);
}
/// <inheritdoc/>

Loading…
Cancel
Save