QueryableExtensions.ContainsAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
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. |
ContainsAsync<TSource>(IQueryable<TSource>, TSource)
Asynchronously determines whether a sequence contains a specified element by using the default equality comparer.
public static System.Threading.Tasks.Task<bool> ContainsAsync<TSource> (this System.Linq.IQueryable<TSource> source, TSource item);
static member ContainsAsync : System.Linq.IQueryable<'Source> * 'Source -> System.Threading.Tasks.Task<bool>
<Extension()>
Public Function ContainsAsync(Of TSource) (source As IQueryable(Of TSource), item As TSource) As Task(Of Boolean)
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IQueryable<TSource>
An IQueryable<T> to return the single element of.
- item
- TSource
The object to locate in the sequence.
Returns
A task that represents the asynchronous operation.
The task result contains true
if the input sequence contains the specified value; otherwise, false
.
Exceptions
source
is
null
.
source
doesn't implement
IDbAsyncQueryProvider
.
Remarks
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.
Applies to
ContainsAsync<TSource>(IQueryable<TSource>, TSource, CancellationToken)
Asynchronously determines whether a sequence contains a specified element by using the default equality comparer.
public static System.Threading.Tasks.Task<bool> ContainsAsync<TSource> (this System.Linq.IQueryable<TSource> source, TSource item, System.Threading.CancellationToken cancellationToken);
static member ContainsAsync : System.Linq.IQueryable<'Source> * 'Source * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IQueryable<TSource>
An IQueryable<T> to return the single element of.
- item
- TSource
The object to locate in the sequence.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation.
The task result contains true
if the input sequence contains the specified value; otherwise, false
.
Exceptions
source
is
null
.
source
doesn't implement
IDbAsyncQueryProvider
.
Remarks
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.
Applies to
Entity Framework