Fix MinimalApi to resolve authorization services per-request
- Resolve ICommandAuthorizationService and IQueryAuthorizationService from request-scoped serviceProvider - Allows Scoped authorization services that depend on DbContext - Updated both MinimalApi and DynamicQuery.MinimalApi Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,11 @@ public abstract class DynamicQueryHandlerBase<TSource, TDestination>
|
||||
protected virtual Task<IQueryable<TSource>> GetQueryableAsync(IDynamicQuery query, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_queryableProviders.Any())
|
||||
return _queryableProviders.ElementAt(0).GetQueryableAsync(query, cancellationToken);
|
||||
{
|
||||
// Use Last() to prefer closed generic registrations (overrides) over open generic (default)
|
||||
// Registration order: open generic first, closed generic (override) last
|
||||
return _queryableProviders.Last().GetQueryableAsync(query, cancellationToken);
|
||||
}
|
||||
|
||||
throw new Exception($"You must provide a QueryableProvider<TSource> for {typeof(TSource).Name}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user