QueryableExtensions.CountAsync Method

Definition

Overloads

CountAsync<TSource>(IQueryable<TSource>)

Asynchronously returns the number of elements in a sequence.

CountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>)

Asynchronously returns the number of elements in a sequence that satisfy a condition.

CountAsync<TSource>(IQueryable<TSource>, CancellationToken)

Asynchronously returns the number of elements in a sequence.

CountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>, CancellationToken)

Asynchronously returns the number of elements in a sequence that satisfy a condition.

CountAsync<TSource>(IQueryable<TSource>)

Asynchronously returns the number of elements in a sequence.

public static System.Threading.Tasks.Task<int> CountAsync<TSource> (this System.Linq.IQueryable<TSource> source);
static member CountAsync : System.Linq.IQueryable<'Source> -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function CountAsync(Of TSource) (source As IQueryable(Of TSource)) As Task(Of Integer)

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IQueryable<TSource>

An IQueryable<T> that contains the elements to be counted.

Returns

A task that represents the asynchronous operation. The task result contains the number of elements in the input sequence.

Exceptions

source is null .

The number of elements in source is larger than MaxValue .

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

CountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>)

Asynchronously returns the number of elements in a sequence that satisfy a condition.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public static System.Threading.Tasks.Task<int> CountAsync<TSource> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,bool>> predicate);
static member CountAsync : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, bool>> -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function CountAsync(Of TSource) (source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean))) As Task(Of Integer)

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IQueryable<TSource>

An IQueryable<T> that contains the elements to be counted.

predicate
Expression<Func<TSource,Boolean>>

A function to test each element for a condition.

Returns

A task that represents the asynchronous operation. The task result contains the number of elements in the sequence that satisfy the condition in the predicate function.

Attributes

Exceptions

source or predicate is null .

The number of elements in source that satisfy the condition in the predicate function is larger than MaxValue .

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

CountAsync<TSource>(IQueryable<TSource>, CancellationToken)

Asynchronously returns the number of elements in a sequence.

public static System.Threading.Tasks.Task<int> CountAsync<TSource> (this System.Linq.IQueryable<TSource> source, System.Threading.CancellationToken cancellationToken);
static member CountAsync : System.Linq.IQueryable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IQueryable<TSource>

An IQueryable<T> that contains the elements to be counted.

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 the number of elements in the input sequence.

Exceptions

source is null .

The number of elements in source is larger than MaxValue .

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

CountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>, CancellationToken)

Asynchronously returns the number of elements in a sequence that satisfy a condition.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public static System.Threading.Tasks.Task<int> CountAsync<TSource> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,bool>> predicate, System.Threading.CancellationToken cancellationToken);
static member CountAsync : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, bool>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IQueryable<TSource>

An IQueryable<T> that contains the elements to be counted.

predicate
Expression<Func<TSource,Boolean>>

A function to test each element for a condition.

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 the number of elements in the sequence that satisfy the condition in the predicate function.

Attributes

Exceptions

source or predicate is null .

The number of elements in source that satisfy the condition in the predicate function is larger than MaxValue .

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