I have the following async method
private async Task<bool> HasPolicy(AuthorizationFilterContext context, string policy)
{
var authorized = await _authorization.AuthorizeAsync(context.HttpContext.User, policy);
return authorized.Succeeded;
}
I would like to use it in Enumerable.All and Enumerable.Any extension
var result1 = IsAndPolicy
? policys.All(async x => await HasPolicy(context, x))
: policys.Any(async x => await HasPolicy(context, x));
But the above code gets the following error
Error CS4010 Cannot convert async lambda expression to delegate type 'Func<string, bool>'. An async lambda expression may return
void,TaskorTask<T>, none of which are convertible to 'Func<string, bool>'.
Anyit should be sequentially and inAllcan be concurrently