QueryableExtensions.AnyAsync Method
Asynchronously determines whether a sequence contains any elements.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() ![]() | AnyAsync<TSource>(IQueryable<TSource>) | Asynchronously determines whether a sequence contains any elements. |
![]() ![]() | AnyAsync<TSource>(IQueryable<TSource>, CancellationToken) | Asynchronously determines whether a sequence contains any elements. |
![]() ![]() | AnyAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, Boolean>>) | Asynchronously determines whether any element of a sequence satisfies a condition. |
![]() ![]() | AnyAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, Boolean>>, CancellationToken) | Asynchronously determines whether any element of a sequence satisfies a condition. |
QueryableExtensions.AnyAsync<TSource> Method (IQueryable<TSource>)
Asynchronously determines whether a sequence contains any elements.
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> to check for being empty.
Return Value
Type: System.Threading.Tasks.Task<Boolean>A task that represents the asynchronous operation. The task result contains true if the source sequence contains any elements; otherwise, false.
Type Parameters
- TSource
The type of the elements of source.
Exception | Condition |
---|---|
ArgumentNullException | source is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
QueryableExtensions.AnyAsync<TSource> Method (IQueryable<TSource>, CancellationToken)
Asynchronously determines whether a sequence contains any elements.
public static Task<bool> AnyAsync<TSource>( this IQueryable<TSource> source, CancellationToken cancellationToken )
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> to check for being empty.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<Boolean>A task that represents the asynchronous operation. The task result contains true if the source sequence contains any elements; otherwise, false.
Type Parameters
- TSource
The type of the elements of source.
Exception | Condition |
---|---|
ArgumentNullException | source is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
QueryableExtensions.AnyAsync<TSource> Method (IQueryable<TSource>, Expression<Func<TSource, Boolean>>)
Asynchronously determines whether any element of a sequence satisfies a condition.
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] public static Task<bool> AnyAsync<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate )
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> whose elements to test for a condition.
- predicate
-
Type:
System.Linq.Expressions.Expression<Func<TSource, Boolean>>
A function to test each element for a condition.
Return Value
Type: System.Threading.Tasks.Task<Boolean>A task that represents the asynchronous operation. The task result contains true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.
Type Parameters
- TSource
The type of the elements of source.
Exception | Condition |
---|---|
ArgumentNullException | source or predicate is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
QueryableExtensions.AnyAsync<TSource> Method (IQueryable<TSource>, Expression<Func<TSource, Boolean>>, CancellationToken)
Asynchronously determines whether any element of a sequence satisfies a condition.
[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] [SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] public static Task<bool> AnyAsync<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken )
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> whose elements to test for a condition.
- predicate
-
Type:
System.Linq.Expressions.Expression<Func<TSource, Boolean>>
A function to test each element for a condition.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<Boolean>A task that represents the asynchronous operation. The task result contains true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.
Type Parameters
- TSource
The type of the elements of source.
Exception | Condition |
---|---|
ArgumentNullException | source or predicate is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.