EntityFrameworkQueryableExtensions EntityFrameworkQueryableExtensions Class

Definition

Entity Framework LINQ related extension methods.

public static class EntityFrameworkQueryableExtensions
Public Module EntityFrameworkQueryableExtensions
Inheritance
System.ObjectSystem.Object
EntityFrameworkQueryableExtensionsEntityFrameworkQueryableExtensions

Inherited Members

System.Object

System.Object.ToString()System.Object.ToString()
System.Object.Equals(System.Object)System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()System.Object.GetHashCode()
System.Object.GetType()System.Object.GetType()
System.Object.MemberwiseClone()System.Object.MemberwiseClone()

Methods

AllAsync(IQueryable, Expression<>>, CancellationToken) AllAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously determines whether all the elements of a sequence satisfy a condition.

public static Task<bool> AllAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AllAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> whose elements to test for a condition.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous operation. The task result contains true if every element of the source sequence passes the test in the specified predicate; otherwise, false.

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.

AnyAsync(IQueryable, Expression<>>, CancellationToken) AnyAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously determines whether any element of a sequence satisfies a condition.

public static Task<bool> AnyAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AnyAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> whose elements to test for a condition.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.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.

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.

AnyAsync(IQueryable, CancellationToken) AnyAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously determines whether a sequence contains any elements.

public static Task<bool> AnyAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AnyAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to check for being empty.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous operation. The task result contains true if the source sequence contains any elements; otherwise, false.

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.

AsNoTracking(IQueryable) AsNoTracking(Of TEntity)(IQueryable(Of TEntity))

Returns a new query where the change tracker will not track any of the entities that are returned. If the entity instances are modified, this will not be detected by the change tracker and SaveChanges() will not persist those changes to the database.

Disabling change tracking is useful for read-only scenarios because it avoids the overhead of setting up change tracking for each entity instance. You should not disable change tracking if you want to manipulate entity instances and persist those changes to the database using SaveChanges().

Identity resolution will still be performed to ensure that all occurrences of an entity with a given key in the result set are represented by the same entity instance.

The default tracking behavior for queries can be controlled by QueryTrackingBehavior.

public static IQueryable<TEntity> AsNoTracking<TEntity>(this IQueryable<TEntity> source)where TEntity : class
<ExtensionAttribute>
Public Shared Function AsNoTracking(Of TEntity As Class)(source As IQueryable(Of TEntity)) As IQueryable(Of TEntity)
Type Parameters
TEntity

The type of entity being queried.

Parameters
source
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

The source query.

Returns
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

A new query where the result set will not be tracked by the context.

AsTracking(IQueryable) AsTracking(Of TEntity)(IQueryable(Of TEntity))

Returns a new query where the change tracker will keep track of changes for all entities that are returned. Any modification to the entity instances will be detected and persisted to the database during SaveChanges().

The default tracking behavior for queries can be controlled by QueryTrackingBehavior.

public static IQueryable<TEntity> AsTracking<TEntity>(this IQueryable<TEntity> source)where TEntity : class
<ExtensionAttribute>
Public Shared Function AsTracking(Of TEntity As Class)(source As IQueryable(Of TEntity)) As IQueryable(Of TEntity)
Type Parameters
TEntity

The type of entity being queried.

Parameters
source
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

The source query.

Returns
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

A new query where the result set will not be tracked by the context.

AverageAsync(IQueryable, CancellationToken) AverageAsync(IQueryable(Of Decimal), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<decimal> AverageAsync(this IQueryable<decimal> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Decimal), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal)
Parameters
source
System.Linq.IQueryable<System.Decimal> System.Linq.IQueryable(Of System.Decimal)

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Decimal> System.Threading.Tasks.Task(Of System.Decimal)

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable, CancellationToken) AverageAsync(IQueryable(Of Double), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<double> AverageAsync(this IQueryable<double> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Double), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Parameters
source
System.Linq.IQueryable<System.Double> System.Linq.IQueryable(Of System.Double)

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable, CancellationToken) AverageAsync(IQueryable(Of Int32), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<double> AverageAsync(this IQueryable<int> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Integer), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Parameters
source
System.Linq.IQueryable<System.Int32> System.Linq.IQueryable(Of System.Int32)

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable, CancellationToken) AverageAsync(IQueryable(Of Int64), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<double> AverageAsync(this IQueryable<long> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Long), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Parameters
source
System.Linq.IQueryable<System.Int64> System.Linq.IQueryable(Of System.Int64)

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable<>>, CancellationToken) AverageAsync(IQueryable(Of Nullable(Of Decimal)), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<decimal ? > AverageAsync(this IQueryable<decimal ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Decimal?), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Decimal>> System.Linq.IQueryable(Of System.Nullable(Of System.Decimal))

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Decimal>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Decimal))

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable<>>, CancellationToken) AverageAsync(IQueryable(Of Nullable(Of Double)), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<double ? > AverageAsync(this IQueryable<double ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Double?), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Double>> System.Linq.IQueryable(Of System.Nullable(Of System.Double))

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable<>>, CancellationToken) AverageAsync(IQueryable(Of Nullable(Of Int32)), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<double ? > AverageAsync(this IQueryable<int ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Integer?), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Int32>> System.Linq.IQueryable(Of System.Nullable(Of System.Int32))

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable<>>, CancellationToken) AverageAsync(IQueryable(Of Nullable(Of Int64)), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<double ? > AverageAsync(this IQueryable<long ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Long?), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Int64>> System.Linq.IQueryable(Of System.Nullable(Of System.Int64))

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable<>>, CancellationToken) AverageAsync(IQueryable(Of Nullable(Of Single)), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<float ? > AverageAsync(this IQueryable<float ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Single?), cancellationToken As CancellationToken = Nothing) As Task(Of Single?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Single>> System.Linq.IQueryable(Of System.Nullable(Of System.Single))

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Single>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Single))

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable, CancellationToken) AverageAsync(IQueryable(Of Single), CancellationToken)

Asynchronously computes the average of a sequence of values.

public static Task<float> AverageAsync(this IQueryable<float> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(source As IQueryable(Of Single), cancellationToken As CancellationToken = Nothing) As Task(Of Single)
Parameters
source
System.Linq.IQueryable<System.Single> System.Linq.IQueryable(Of System.Single)

A sequence of values to calculate the average of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Single> System.Threading.Tasks.Task(Of System.Single)

A task that represents the asynchronous operation. The task result contains the average of the sequence of values.

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.

AverageAsync(IQueryable, Expression<>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Decimal)), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<decimal> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Decimal)), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Decimal>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Decimal))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Decimal> System.Threading.Tasks.Task(Of System.Decimal)

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Double)), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Double)), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Double>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Double))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Int32)), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Integer)), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Int32>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Int32))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Int64)), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Long)), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Int64>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Int64))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Decimal))), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<decimal ? > AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Decimal?)), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal?)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Decimal>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Decimal)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Decimal>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Decimal))

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Double))), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double ? > AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Double?)), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Double>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Double)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Int32))), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double ? > AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Integer?)), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Int32>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Int32)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Int64))), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double ? > AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Long?)), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Int64>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Int64)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Single))), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<float ? > AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Single?)), cancellationToken As CancellationToken = Nothing) As Task(Of Single?)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Single>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Single)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Single>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Single))

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

AverageAsync(IQueryable, Expression<>>, CancellationToken) AverageAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Single)), CancellationToken)

Asynchronously computes the average of a sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<float> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function AverageAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Single)), cancellationToken As CancellationToken = Nothing) As Task(Of Single)
Type Parameters
TSource

The type of the elements of source .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Single>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Single))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Single> System.Threading.Tasks.Task(Of System.Single)

A task that represents the asynchronous operation. The task result contains the average of the projected values.

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.

ContainsAsync(IQueryable, TSource, CancellationToken) ContainsAsync(Of TSource)(IQueryable(Of TSource), TSource, CancellationToken)

Asynchronously determines whether a sequence contains a specified element by using the default equality comparer.

public static Task<bool> ContainsAsync<TSource>(this IQueryable<TSource> source, TSource item, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ContainsAsync(Of TSource)(source As IQueryable(Of TSource), item As TSource, cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the single element of.

item
TSource TSource

The object to locate in the sequence.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Boolean> System.Threading.Tasks.Task(Of System.Boolean)

A task that represents the asynchronous operation. The task result contains true if the input sequence contains the specified value; otherwise, false.

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.

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

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

public static Task<int> CountAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function CountAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of Integer)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

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

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int32> System.Threading.Tasks.Task(Of System.Int32)

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.

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.

CountAsync(IQueryable, CancellationToken) CountAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the number of elements in a sequence.

public static Task<int> CountAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function CountAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of Integer)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

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

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int32> System.Threading.Tasks.Task(Of System.Int32)

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

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.

FirstAsync(IQueryable, Expression<>>, CancellationToken) FirstAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns the first element of a sequence that satisfies a specified condition.

public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function FirstAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the first element of.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the first element in source that passes the test in predicate.

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.

FirstAsync(IQueryable, CancellationToken) FirstAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the first element of a sequence.

public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function FirstAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the first element of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the first element in source.

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.

FirstOrDefaultAsync(IQueryable, Expression<>>, CancellationToken) FirstOrDefaultAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns the first element of a sequence that satisfies a specified condition or a default value if no such element is found.

public static Task<TSource> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function FirstOrDefaultAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the first element of.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains default ( TSource ) if source is empty or if no element passes the test specified by predicate ; otherwise, the first element in source that passes the test specified by predicate.

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.

FirstOrDefaultAsync(IQueryable, CancellationToken) FirstOrDefaultAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the first element of a sequence, or a default value if the sequence contains no elements.

public static Task<TSource> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function FirstOrDefaultAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the first element of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains default ( TSource ) if source is empty; otherwise, the first element in source.

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.

ForEachAsync(IQueryable, Action, CancellationToken) ForEachAsync(Of T)(IQueryable(Of T), Action(Of T), CancellationToken)

Asynchronously enumerates the query results and performs the specified action on each element.

public static Task ForEachAsync<T>(this IQueryable<T> source, Action<T> action, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ForEachAsync(Of T)(source As IQueryable(Of T), action As Action(Of T), cancellationToken As CancellationToken = Nothing) As Task
Type Parameters
T

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<T> System.Linq.IQueryable(Of T)

An System.Linq.IQueryable<T> to enumerate.

action
System.Action<T> System.Action(Of T)

The action to perform on each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

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.

Include(IQueryable, String) Include(Of TEntity)(IQueryable(Of TEntity), String)

Specifies related entities to include in the query results. The navigation property to be included is specified starting with the type of entity being queried (TEntity). Further navigation properties to be included can be appended, separated by the '.' character.

public static IQueryable<TEntity> Include<TEntity>(this IQueryable<TEntity> source, string navigationPropertyPath)where TEntity : class
<ExtensionAttribute>
Public Shared Function Include(Of TEntity As Class)(source As IQueryable(Of TEntity), navigationPropertyPath As String) As IQueryable(Of TEntity)
Type Parameters
TEntity

The type of entity being queried.

Parameters
source
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

The source query.

navigationPropertyPath
System.String System.String

A string of '.' separated navigation property names to be included.

Returns
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

A new query with the related data included.

Examples

The following query shows including a single level of related entities.

    context.Blogs.Include("Posts");

The following query shows including two levels of entities on the same branch.

    context.Blogs.Include("Posts.Tags");

The following query shows including multiple levels and branches of related data.

    context.Blogs
        .Include("Posts.Tags.TagInfo')
        .Include("Contributors");

Include(IQueryable, Expression<>>) Include(Of TEntity, TProperty)(IQueryable(Of TEntity), Expression(Of Func(Of TEntity, TProperty)))

Specifies related entities to include in the query results. The navigation property to be included is specified starting with the type of entity being queried (TEntity). If you wish to include additional types based on the navigation properties of the type being included, then chain a call to ThenInclude<TEntity, TPreviousProperty, TProperty>(IIncludableQueryable<TEntity, IEnumerable<TPreviousProperty>>, Expression<Func<TPreviousProperty, TProperty>>) after this call.

public static IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(this IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)where TEntity : class
<ExtensionAttribute>
Public Shared Function Include(Of TEntity As Class, TProperty)(source As IQueryable(Of TEntity), navigationPropertyPath As Expression(Of Func(Of TEntity, TProperty))) As IIncludableQueryable(Of TEntity, TProperty)
Type Parameters
TEntity

The type of entity being queried.

TProperty

The type of the related entity to be included.

Parameters
source
System.Linq.IQueryable<TEntity> System.Linq.IQueryable(Of TEntity)

The source query.

navigationPropertyPath
System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> System.Linq.Expressions.Expression(Of System.Func(Of TEntity, TProperty))

A lambda expression representing the navigation property to be included (t => t.Property1).

Returns
IIncludableQueryable<TEntity, TProperty> IIncludableQueryable(Of TEntity, TProperty)

A new query with the related data included.

Examples

The following query shows including a single level of related entities.

    context.Blogs.Include(blog => blog.Posts);

The following query shows including two levels of entities on the same branch.

    context.Blogs
        .Include(blog => blog.Posts).ThenInclude(post => post.Tags);

The following query shows including multiple levels and branches of related data.

    context.Blogs
        .Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
        .Include(blog => blog.Contributors);

LastAsync(IQueryable, Expression<>>, CancellationToken) LastAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns the last element of a sequence that satisfies a specified condition.

public static Task<TSource> LastAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LastAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the last element of.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the last element in source that passes the test in predicate.

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.

LastAsync(IQueryable, CancellationToken) LastAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the last element of a sequence.

public static Task<TSource> LastAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LastAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the last element of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the last element in source.

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.

LastOrDefaultAsync(IQueryable, Expression<>>, CancellationToken) LastOrDefaultAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns the last element of a sequence that satisfies a specified condition or a default value if no such element is found.

public static Task<TSource> LastOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LastOrDefaultAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the last element of.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains default ( TSource ) if source is empty or if no element passes the test specified by predicate ; otherwise, the last element in source that passes the test specified by predicate.

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.

LastOrDefaultAsync(IQueryable, CancellationToken) LastOrDefaultAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the last element of a sequence, or a default value if the sequence contains no elements.

public static Task<TSource> LastOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LastOrDefaultAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the last element of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains default ( TSource ) if source is empty; otherwise, the last element in source.

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.

Load(IQueryable) Load(Of TSource)(IQueryable(Of TSource))

Enumerates the query. When using Entity Framework, this causes the results of the query to be loaded into the associated context. This is equivalent to calling ToList and then throwing away the list (without the overhead of actually creating the list).

public static void Load<TSource>(this IQueryable<TSource> source)
<ExtensionAttribute>
Public Shared Sub Load(Of TSource)(source As IQueryable(Of TSource))
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

The source query.

LoadAsync(IQueryable, CancellationToken) LoadAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously enumerates the query. When using Entity Framework, this causes the results of the query to be loaded into the associated context. This is equivalent to calling ToList and then throwing away the list (without the overhead of actually creating the list).

public static Task LoadAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LoadAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

The source query.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

LongCountAsync(IQueryable, Expression<>>, CancellationToken) LongCountAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns an System.Int64 that represents the number of elements in a sequence that satisfy a condition.

public static Task<long> LongCountAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LongCountAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of Long)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

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

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test each element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int64> System.Threading.Tasks.Task(Of System.Int64)

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.

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.

LongCountAsync(IQueryable, CancellationToken) LongCountAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns an System.Int64 that represents the total number of elements in a sequence.

public static Task<long> LongCountAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function LongCountAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of Long)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

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

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int64> System.Threading.Tasks.Task(Of System.Int64)

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

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.

MaxAsync(IQueryable, CancellationToken) MaxAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the maximum value of a sequence.

public static Task<TSource> MaxAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function MaxAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> that contains the elements to determine the maximum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the maximum value in the sequence.

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.

MaxAsync(IQueryable, Expression<>>, CancellationToken) MaxAsync(Of TSource, TResult)(IQueryable(Of TSource), Expression(Of Func(Of TSource, TResult)), CancellationToken)

Asynchronously invokes a projection function on each element of a sequence and returns the maximum resulting value.

public static Task<TResult> MaxAsync<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function MaxAsync(Of TSource, TResult)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, TResult)), cancellationToken As CancellationToken = Nothing) As Task(Of TResult)
Type Parameters
TSource

The type of the elements of source.

TResult

The type of the value returned by the function represented by selector .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> that contains the elements to determine the maximum of.

selector
System.Linq.Expressions.Expression<System.Func<TSource, TResult>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, TResult))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TResult> System.Threading.Tasks.Task(Of TResult)

A task that represents the asynchronous operation. The task result contains the maximum value in the sequence.

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.

MinAsync(IQueryable, CancellationToken) MinAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the minimum value of a sequence.

public static Task<TSource> MinAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function MinAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> that contains the elements to determine the minimum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the minimum value in the sequence.

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.

MinAsync(IQueryable, Expression<>>, CancellationToken) MinAsync(Of TSource, TResult)(IQueryable(Of TSource), Expression(Of Func(Of TSource, TResult)), CancellationToken)

Asynchronously invokes a projection function on each element of a sequence and returns the minimum resulting value.

public static Task<TResult> MinAsync<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function MinAsync(Of TSource, TResult)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, TResult)), cancellationToken As CancellationToken = Nothing) As Task(Of TResult)
Type Parameters
TSource

The type of the elements of source.

TResult

The type of the value returned by the function represented by selector .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> that contains the elements to determine the minimum of.

selector
System.Linq.Expressions.Expression<System.Func<TSource, TResult>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, TResult))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TResult> System.Threading.Tasks.Task(Of TResult)

A task that represents the asynchronous operation. The task result contains the minimum value in the sequence.

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.

SingleAsync(IQueryable, Expression<>>, CancellationToken) SingleAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

public static Task<TSource> SingleAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SingleAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the single element of.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test an element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the single element of the input sequence that satisfies the condition in predicate.

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.

SingleAsync(IQueryable, CancellationToken) SingleAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

public static Task<TSource> SingleAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SingleAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the single element of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the single element of the input sequence.

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.

SingleOrDefaultAsync(IQueryable, Expression<>>, CancellationToken) SingleOrDefaultAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Boolean)), CancellationToken)

Asynchronously returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

public static Task<TSource> SingleOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SingleOrDefaultAsync(Of TSource)(source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the single element of.

predicate
System.Linq.Expressions.Expression<System.Func<TSource, System.Boolean>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Boolean))

A function to test an element for a condition.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the single element of the input sequence that satisfies the condition in predicate, or default ( TSource ) if no such element is found.

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.

SingleOrDefaultAsync(IQueryable, CancellationToken) SingleOrDefaultAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

public static Task<TSource> SingleOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SingleOrDefaultAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to return the single element of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource> System.Threading.Tasks.Task(Of TSource)

A task that represents the asynchronous operation. The task result contains the single element of the input sequence, or default ( TSource) if the sequence contains no elements.

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.

SumAsync(IQueryable, CancellationToken) SumAsync(IQueryable(Of Decimal), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<decimal> SumAsync(this IQueryable<decimal> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Decimal), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal)
Parameters
source
System.Linq.IQueryable<System.Decimal> System.Linq.IQueryable(Of System.Decimal)

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Decimal> System.Threading.Tasks.Task(Of System.Decimal)

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable, CancellationToken) SumAsync(IQueryable(Of Double), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<double> SumAsync(this IQueryable<double> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Double), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Parameters
source
System.Linq.IQueryable<System.Double> System.Linq.IQueryable(Of System.Double)

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable, CancellationToken) SumAsync(IQueryable(Of Int32), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<int> SumAsync(this IQueryable<int> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Integer), cancellationToken As CancellationToken = Nothing) As Task(Of Integer)
Parameters
source
System.Linq.IQueryable<System.Int32> System.Linq.IQueryable(Of System.Int32)

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int32> System.Threading.Tasks.Task(Of System.Int32)

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable, CancellationToken) SumAsync(IQueryable(Of Int64), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<long> SumAsync(this IQueryable<long> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Long), cancellationToken As CancellationToken = Nothing) As Task(Of Long)
Parameters
source
System.Linq.IQueryable<System.Int64> System.Linq.IQueryable(Of System.Int64)

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int64> System.Threading.Tasks.Task(Of System.Int64)

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable<>>, CancellationToken) SumAsync(IQueryable(Of Nullable(Of Decimal)), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<decimal ? > SumAsync(this IQueryable<decimal ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Decimal?), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Decimal>> System.Linq.IQueryable(Of System.Nullable(Of System.Decimal))

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Decimal>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Decimal))

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable<>>, CancellationToken) SumAsync(IQueryable(Of Nullable(Of Double)), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<double ? > SumAsync(this IQueryable<double ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Double?), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Double>> System.Linq.IQueryable(Of System.Nullable(Of System.Double))

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable<>>, CancellationToken) SumAsync(IQueryable(Of Nullable(Of Int32)), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<int ? > SumAsync(this IQueryable<int ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Integer?), cancellationToken As CancellationToken = Nothing) As Task(Of Integer?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Int32>> System.Linq.IQueryable(Of System.Nullable(Of System.Int32))

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Int32>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Int32))

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable<>>, CancellationToken) SumAsync(IQueryable(Of Nullable(Of Int64)), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<long ? > SumAsync(this IQueryable<long ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Long?), cancellationToken As CancellationToken = Nothing) As Task(Of Long?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Int64>> System.Linq.IQueryable(Of System.Nullable(Of System.Int64))

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Int64>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Int64))

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable<>>, CancellationToken) SumAsync(IQueryable(Of Nullable(Of Single)), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<float ? > SumAsync(this IQueryable<float ? > source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Single?), cancellationToken As CancellationToken = Nothing) As Task(Of Single?)
Parameters
source
System.Linq.IQueryable<System.Nullable<System.Single>> System.Linq.IQueryable(Of System.Nullable(Of System.Single))

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Single>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Single))

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable, CancellationToken) SumAsync(IQueryable(Of Single), CancellationToken)

Asynchronously computes the sum of a sequence of values.

public static Task<float> SumAsync(this IQueryable<float> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(source As IQueryable(Of Single), cancellationToken As CancellationToken = Nothing) As Task(Of Single)
Parameters
source
System.Linq.IQueryable<System.Single> System.Linq.IQueryable(Of System.Single)

A sequence of values to calculate the sum of.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Single> System.Threading.Tasks.Task(Of System.Single)

A task that represents the asynchronous operation. The task result contains the sum of the values in the sequence.

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.

SumAsync(IQueryable, Expression<>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Decimal)), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<decimal> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Decimal)), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Decimal>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Decimal))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Decimal> System.Threading.Tasks.Task(Of System.Decimal)

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Double)), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Double)), cancellationToken As CancellationToken = Nothing) As Task(Of Double)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Double>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Double))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Double> System.Threading.Tasks.Task(Of System.Double)

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Int32)), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<int> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Integer)), cancellationToken As CancellationToken = Nothing) As Task(Of Integer)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Int32>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Int32))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int32> System.Threading.Tasks.Task(Of System.Int32)

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Int64)), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<long> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Long)), cancellationToken As CancellationToken = Nothing) As Task(Of Long)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Int64>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Int64))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Int64> System.Threading.Tasks.Task(Of System.Int64)

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Decimal))), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<decimal ? > SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Decimal?)), cancellationToken As CancellationToken = Nothing) As Task(Of Decimal?)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Decimal>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Decimal)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Decimal>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Decimal))

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Double))), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double ? > SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Double?)), cancellationToken As CancellationToken = Nothing) As Task(Of Double?)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Double>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Double)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Double>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Double))

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Int32))), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<int ? > SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Integer?)), cancellationToken As CancellationToken = Nothing) As Task(Of Integer?)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Int32>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Int32)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Int32>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Int32))

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Int64))), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<long ? > SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Long?)), cancellationToken As CancellationToken = Nothing) As Task(Of Long?)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Int64>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Int64)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Int64>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Int64))

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Nullable(Of Single))), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<float ? > SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float ? >> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Single?)), cancellationToken As CancellationToken = Nothing) As Task(Of Single?)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Nullable<System.Single>>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Nullable(Of System.Single)))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Nullable<System.Single>> System.Threading.Tasks.Task(Of System.Nullable(Of System.Single))

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

SumAsync(IQueryable, Expression<>>, CancellationToken) SumAsync(Of TSource)(IQueryable(Of TSource), Expression(Of Func(Of TSource, Single)), CancellationToken)

Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<float> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function SumAsync(Of TSource)(source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, Single)), cancellationToken As CancellationToken = Nothing) As Task(Of Single)
Type Parameters
TSource
Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

A sequence of values of type TSource.

selector
System.Linq.Expressions.Expression<System.Func<TSource, System.Single>> System.Linq.Expressions.Expression(Of System.Func(Of TSource, System.Single))

A projection function to apply to each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Single> System.Threading.Tasks.Task(Of System.Single)

A task that represents the asynchronous operation. The task result contains the sum of the projected values..

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.

ThenInclude(IIncludableQueryable, Expression<>>) ThenInclude(Of TEntity, TPreviousProperty, TProperty)(IIncludableQueryable(Of TEntity, TPreviousProperty), Expression(Of Func(Of TPreviousProperty, TProperty)))

Specifies additional related data to be further included based on a related type that was just included.

public static IIncludableQueryable<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty>(this IIncludableQueryable<TEntity, TPreviousProperty> source, Expression<Func<TPreviousProperty, TProperty>> navigationPropertyPath)where TEntity : class
<ExtensionAttribute>
Public Shared Function ThenInclude(Of TEntity As Class, TPreviousProperty, TProperty)(source As IIncludableQueryable(Of TEntity, TPreviousProperty), navigationPropertyPath As Expression(Of Func(Of TPreviousProperty, TProperty))) As IIncludableQueryable(Of TEntity, TProperty)
Type Parameters
TEntity

The type of entity being queried.

TPreviousProperty

The type of the entity that was just included.

TProperty

The type of the related entity to be included.

Parameters
source
IIncludableQueryable<TEntity, TPreviousProperty> IIncludableQueryable(Of TEntity, TPreviousProperty)

The source query.

navigationPropertyPath
System.Linq.Expressions.Expression<System.Func<TPreviousProperty, TProperty>> System.Linq.Expressions.Expression(Of System.Func(Of TPreviousProperty, TProperty))

A lambda expression representing the navigation property to be included (t => t.Property1).

Returns
IIncludableQueryable<TEntity, TProperty> IIncludableQueryable(Of TEntity, TProperty)

A new query with the related data included.

Examples

The following query shows including a single level of related entities.

    context.Blogs.Include(blog => blog.Posts);

The following query shows including two levels of entities on the same branch.

    context.Blogs
        .Include(blog => blog.Posts).ThenInclude(post => post.Tags);

The following query shows including multiple levels and branches of related data.

    context.Blogs
        .Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
        .Include(blog => blog.Contributors);

ThenInclude(IIncludableQueryable>, Expression<>>) ThenInclude(Of TEntity, TPreviousProperty, TProperty)(IIncludableQueryable(Of TEntity, IEnumerable(Of TPreviousProperty)), Expression(Of Func(Of TPreviousProperty, TProperty)))

Specifies additional related data to be further included based on a related type that was just included.

public static IIncludableQueryable<TEntity, TProperty> ThenInclude<TEntity, TPreviousProperty, TProperty>(this IIncludableQueryable<TEntity, IEnumerable<TPreviousProperty>> source, Expression<Func<TPreviousProperty, TProperty>> navigationPropertyPath)where TEntity : class
<ExtensionAttribute>
Public Shared Function ThenInclude(Of TEntity As Class, TPreviousProperty, TProperty)(source As IIncludableQueryable(Of TEntity, IEnumerable(Of TPreviousProperty)), navigationPropertyPath As Expression(Of Func(Of TPreviousProperty, TProperty))) As IIncludableQueryable(Of TEntity, TProperty)
Type Parameters
TEntity

The type of entity being queried.

TPreviousProperty

The type of the entity that was just included.

TProperty

The type of the related entity to be included.

Parameters
source
IIncludableQueryable<TEntity, System.Collections.Generic.IEnumerable<TPreviousProperty>> IIncludableQueryable(Of TEntity, System.Collections.Generic.IEnumerable(Of TPreviousProperty))

The source query.

navigationPropertyPath
System.Linq.Expressions.Expression<System.Func<TPreviousProperty, TProperty>> System.Linq.Expressions.Expression(Of System.Func(Of TPreviousProperty, TProperty))

A lambda expression representing the navigation property to be included (t => t.Property1).

Returns
IIncludableQueryable<TEntity, TProperty> IIncludableQueryable(Of TEntity, TProperty)

A new query with the related data included.

Examples

The following query shows including a single level of related entities.

    context.Blogs.Include(blog => blog.Posts);

The following query shows including two levels of entities on the same branch.

    context.Blogs
        .Include(blog => blog.Posts).ThenInclude(post => post.Tags);

The following query shows including multiple levels and branches of related data.

    context.Blogs
        .Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
        .Include(blog => blog.Contributors);

ToArrayAsync(IQueryable, CancellationToken) ToArrayAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously creates an array from an System.Linq.IQueryable<T> by enumerating it asynchronously.

public static Task<TSource[]> ToArrayAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ToArrayAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of TSource())
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to create an array from.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<TSource[]> System.Threading.Tasks.Task(Of TSource())

A task that represents the asynchronous operation. The task result contains an array that contains elements from the input sequence.

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.

ToDictionaryAsync(IQueryable, Func, IEqualityComparer, CancellationToken) ToDictionaryAsync(Of TSource, TKey)(IQueryable(Of TSource), Func(Of TSource, TKey), IEqualityComparer(Of TKey), CancellationToken)

Creates a System.Collections.Generic.Dictionary<TKey, TValue> from an System.Linq.IQueryable<T> by enumerating it asynchronously according to a specified key selector function and a comparer.

public static Task<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ToDictionaryAsync(Of TSource, TKey)(source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), comparer As IEqualityComparer(Of TKey), cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TSource))
Type Parameters
TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to create a System.Collections.Generic.Dictionary<TKey, TValue> from.

keySelector
System.Func<TSource, TKey> System.Func(Of TSource, TKey)

A function to extract a key from each element.

comparer
System.Collections.Generic.IEqualityComparer<TKey> System.Collections.Generic.IEqualityComparer(Of TKey)

An System.Collections.Generic.IEqualityComparer<T> to compare keys.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey, TSource>> System.Threading.Tasks.Task(Of System.Collections.Generic.Dictionary(Of TKey, TSource))

A task that represents the asynchronous operation. The task result contains a System.Collections.Generic.Dictionary<TKey, TValue> that contains selected keys and values.

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.

ToDictionaryAsync(IQueryable, Func, CancellationToken) ToDictionaryAsync(Of TSource, TKey)(IQueryable(Of TSource), Func(Of TSource, TKey), CancellationToken)

Creates a System.Collections.Generic.Dictionary<TKey, TValue> from an System.Linq.IQueryable<T> by enumerating it asynchronously according to a specified key selector function.

public static Task<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ToDictionaryAsync(Of TSource, TKey)(source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TSource))
Type Parameters
TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector .

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to create a System.Collections.Generic.Dictionary<TKey, TValue> from.

keySelector
System.Func<TSource, TKey> System.Func(Of TSource, TKey)

A function to extract a key from each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey, TSource>> System.Threading.Tasks.Task(Of System.Collections.Generic.Dictionary(Of TKey, TSource))

A task that represents the asynchronous operation. The task result contains a System.Collections.Generic.Dictionary<TKey, TValue> that contains selected keys and values.

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.

ToDictionaryAsync(IQueryable, Func, Func, IEqualityComparer, CancellationToken) ToDictionaryAsync(Of TSource, TKey, TElement)(IQueryable(Of TSource), Func(Of TSource, TKey), Func(Of TSource, TElement), IEqualityComparer(Of TKey), CancellationToken)

Creates a System.Collections.Generic.Dictionary<TKey, TValue> from an System.Linq.IQueryable<T> by enumerating it asynchronously according to a specified key selector function, a comparer, and an element selector function.

public static Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ToDictionaryAsync(Of TSource, TKey, TElement)(source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), comparer As IEqualityComparer(Of TKey), cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TElement))
Type Parameters
TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector .

TElement

The type of the value returned by elementSelector.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to create a System.Collections.Generic.Dictionary<TKey, TValue> from.

keySelector
System.Func<TSource, TKey> System.Func(Of TSource, TKey)

A function to extract a key from each element.

elementSelector
System.Func<TSource, TElement> System.Func(Of TSource, TElement)

A transform function to produce a result element value from each element.

comparer
System.Collections.Generic.IEqualityComparer<TKey> System.Collections.Generic.IEqualityComparer(Of TKey)

An System.Collections.Generic.IEqualityComparer<T> to compare keys.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey, TElement>> System.Threading.Tasks.Task(Of System.Collections.Generic.Dictionary(Of TKey, TElement))

A task that represents the asynchronous operation. The task result contains a System.Collections.Generic.Dictionary<TKey, TValue> that contains values of type TElement selected from the input sequence.

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.

ToDictionaryAsync(IQueryable, Func, Func, CancellationToken) ToDictionaryAsync(Of TSource, TKey, TElement)(IQueryable(Of TSource), Func(Of TSource, TKey), Func(Of TSource, TElement), CancellationToken)

Creates a System.Collections.Generic.Dictionary<TKey, TValue> from an System.Linq.IQueryable<T> by enumerating it asynchronously according to a specified key selector and an element selector function.

public static Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ToDictionaryAsync(Of TSource, TKey, TElement)(source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TElement))
Type Parameters
TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector .

TElement

The type of the value returned by elementSelector.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to create a System.Collections.Generic.Dictionary<TKey, TValue> from.

keySelector
System.Func<TSource, TKey> System.Func(Of TSource, TKey)

A function to extract a key from each element.

elementSelector
System.Func<TSource, TElement> System.Func(Of TSource, TElement)

A transform function to produce a result element value from each element.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey, TElement>> System.Threading.Tasks.Task(Of System.Collections.Generic.Dictionary(Of TKey, TElement))

A task that represents the asynchronous operation. The task result contains a System.Collections.Generic.Dictionary<TKey, TValue> that contains values of type TElement selected from the input sequence.

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.

ToListAsync(IQueryable, CancellationToken) ToListAsync(Of TSource)(IQueryable(Of TSource), CancellationToken)

Asynchronously creates a System.Collections.Generic.List<T> from an System.Linq.IQueryable<T> by enumerating it asynchronously.

public static Task<List<TSource>> ToListAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
<ExtensionAttribute>
Public Shared Function ToListAsync(Of TSource)(source As IQueryable(Of TSource), cancellationToken As CancellationToken = Nothing) As Task(Of List(Of TSource))
Type Parameters
TSource

The type of the elements of source.

Parameters
source
System.Linq.IQueryable<TSource> System.Linq.IQueryable(Of TSource)

An System.Linq.IQueryable<T> to create a list from.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<System.Collections.Generic.List<TSource>> System.Threading.Tasks.Task(Of System.Collections.Generic.List(Of TSource))

A task that represents the asynchronous operation. The task result contains a System.Collections.Generic.List<T> that contains elements from the input sequence.

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.