QueryableExtensions::ContainsAsync Method
Asynchronously determines whether a sequence contains a specified element by using the default equality comparer.
Assembly: EntityFramework (in EntityFramework.dll)
| Name | Description | |
|---|---|---|
![]() ![]() | ContainsAsync<TSource>(IQueryable<TSource>^, TSource) | Asynchronously determines whether a sequence contains a specified element by using the default equality comparer. |
![]() ![]() | ContainsAsync<TSource>(IQueryable<TSource>^, TSource, CancellationToken) | Asynchronously determines whether a sequence contains a specified element by using the default equality comparer. |
QueryableExtensions::ContainsAsync<TSource> Method (IQueryable<TSource>^, TSource)
Asynchronously determines whether a sequence contains a specified element by using the default equality comparer.
public: generic<typename TSource> [ExtensionAttribute] static Task<bool>^ ContainsAsync( IQueryable<TSource>^ source, TSource item )
Parameters
- source
-
Type:
System.Linq::IQueryable<TSource>^
An IQueryable<T> to return the single element of.
- item
-
Type:
TSource
The object to locate in the sequence.
Return Value
Type: System.Threading.Tasks::Task<Boolean>^A task that represents the asynchronous operation. The task result contains true if the input sequence contains the specified value; 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::ContainsAsync<TSource> Method (IQueryable<TSource>^, TSource, CancellationToken)
Asynchronously determines whether a sequence contains a specified element by using the default equality comparer.
public: generic<typename TSource> [ExtensionAttribute] static Task<bool>^ ContainsAsync( IQueryable<TSource>^ source, TSource item, CancellationToken cancellationToken )
Parameters
- source
-
Type:
System.Linq::IQueryable<TSource>^
An IQueryable<T> to return the single element of.
- item
-
Type:
TSource
The object to locate in the sequence.
- 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 input sequence contains the specified value; 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.

