EntityFrameworkQueryableExtensions Class

Definition

Entity Framework LINQ related extension methods.

public static class EntityFrameworkQueryableExtensions
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2060", Justification="MakeGenericMethod is used in this class to create MethodCallExpression nodes, but only if the method in question is called from user code - so it's never trimmed. After https://github.com/dotnet/linker/issues/2482 is fixed, the suppression will no longer be necessary.")]
public static class EntityFrameworkQueryableExtensions
type EntityFrameworkQueryableExtensions = class
[<System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2060", Justification="MakeGenericMethod is used in this class to create MethodCallExpression nodes, but only if the method in question is called from user code - so it's never trimmed. After https://github.com/dotnet/linker/issues/2482 is fixed, the suppression will no longer be necessary.")>]
type EntityFrameworkQueryableExtensions = class
Public Module EntityFrameworkQueryableExtensions
Inheritance
EntityFrameworkQueryableExtensions
Attributes

Methods

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

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

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

Asynchronously determines whether a sequence contains any elements.

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

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

AsAsyncEnumerable<TSource>(IQueryable<TSource>)

Returns an IAsyncEnumerable<T> which can be enumerated asynchronously.

AsNoTracking<TEntity>(IQueryable<TEntity>)

The change tracker will not track any of the entities that are returned from a LINQ query. 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.

AsNoTrackingWithIdentityResolution<TEntity>(IQueryable<TEntity>)

The change tracker will not track any of the entities that are returned from a LINQ query. 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.

AsTracking<TEntity>(IQueryable<TEntity>, QueryTrackingBehavior)

Returns a new query where the change tracker will either keep track of changes or not for all entities that are returned, depending on the value of the 'track' parameter. When tracking, Any modification to the entity instances will be detected and persisted to the database during SaveChanges(). When not tracking, 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.

AsTracking<TEntity>(IQueryable<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().

AverageAsync(IQueryable<Decimal>, CancellationToken)

Asynchronously computes the average of a sequence of values.

AverageAsync(IQueryable<Double>, CancellationToken)

Asynchronously computes the average of a sequence of values.

AverageAsync(IQueryable<Int32>, CancellationToken)

Asynchronously computes the average of a sequence of values.

AverageAsync(IQueryable<Int64>, CancellationToken)

Asynchronously computes the average of a sequence of values.

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

Asynchronously computes the average of a sequence of values.

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

Asynchronously computes the average of a sequence of values.

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

Asynchronously computes the average of a sequence of values.

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

Asynchronously computes the average of a sequence of values.

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

Asynchronously computes the average of a sequence of values.

AverageAsync(IQueryable<Single>, CancellationToken)

Asynchronously computes the average of a sequence of values.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

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

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

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

Asynchronously returns the number of elements in a sequence.

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

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

ElementAtAsync<TSource>(IQueryable<TSource>, Int32, CancellationToken)

Asynchronously returns the element at a specified index in a sequence.

ElementAtOrDefaultAsync<TSource>(IQueryable<TSource>, Int32, CancellationToken)

Asynchronously returns the element at a specified index in a sequence, or a default value if the index is out of range.

ExecuteDelete<TSource>(IQueryable<TSource>)

Deletes all database rows for the entity instances which match the LINQ query from the database.

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

Asynchronously deletes database rows for the entity instances which match the LINQ query from the database.

ExecuteUpdate<TSource>(IQueryable<TSource>, Expression<Func<SetPropertyCalls<TSource>,SetPropertyCalls<TSource>>>)

Updates all database rows for the entity instances which match the LINQ query from the database.

ExecuteUpdateAsync<TSource>(IQueryable<TSource>, Expression<Func<SetPropertyCalls<TSource>,SetPropertyCalls<TSource>>>, CancellationToken)

Asynchronously updates database rows for the entity instances which match the LINQ query from the database.

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

Asynchronously returns the first element of a sequence.

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

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

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

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

FirstOrDefaultAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

ForEachAsync<T>(IQueryable<T>, Action<T>, CancellationToken)

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

IgnoreAutoIncludes<TEntity>(IQueryable<TEntity>)

Specifies that the current Entity Framework LINQ query should not have any model-level eager loaded navigations applied.

IgnoreQueryFilters<TEntity>(IQueryable<TEntity>)

Specifies that the current Entity Framework LINQ query should not have any model-level entity query filters applied.

Include<TEntity,TProperty>(IQueryable<TEntity>, Expression<Func<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.

Include<TEntity>(IQueryable<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.

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

Asynchronously returns the last element of a sequence.

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

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

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

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

LastOrDefaultAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

Load<TSource>(IQueryable<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).

LoadAsync<TSource>(IQueryable<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).

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

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

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

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

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

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

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

Asynchronously returns the maximum value of a sequence.

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

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

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

Asynchronously returns the minimum value of a sequence.

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

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

SingleAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

SingleOrDefaultAsync<TSource>(IQueryable<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.

SingleOrDefaultAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

SumAsync(IQueryable<Decimal>, CancellationToken)

Asynchronously computes the sum of a sequence of values.

SumAsync(IQueryable<Double>, CancellationToken)

Asynchronously computes the sum of a sequence of values.

SumAsync(IQueryable<Int32>, CancellationToken)

Asynchronously computes the sum of a sequence of values.

SumAsync(IQueryable<Int64>, CancellationToken)

Asynchronously computes the sum of a sequence of values.

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

Asynchronously computes the sum of a sequence of values.

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

Asynchronously computes the sum of a sequence of values.

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

Asynchronously computes the sum of a sequence of values.

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

Asynchronously computes the sum of a sequence of values.

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

Asynchronously computes the sum of a sequence of values.

SumAsync(IQueryable<Single>, CancellationToken)

Asynchronously computes the sum of a sequence of values.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource,Nullable<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.

SumAsync<TSource>(IQueryable<TSource>, Expression<Func<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.

TagWith<T>(IQueryable<T>, String)

Adds a tag to the collection of tags associated with an EF LINQ query. Tags are query annotations that can provide contextual tracing information at different points in the query pipeline.

TagWithCallSite<T>(IQueryable<T>, String, Int32)

Adds a tag to the collection of tags associated with an EF LINQ query with source file name and line where method was called that can provide contextual tracing information at different points in the query pipeline.

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

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

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

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

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

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

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

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

ToDictionaryAsync<TSource,TKey,TElement>(IQueryable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, CancellationToken)

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

ToDictionaryAsync<TSource,TKey,TElement>(IQueryable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)

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

ToDictionaryAsync<TSource,TKey>(IQueryable<TSource>, Func<TSource,TKey>, CancellationToken)

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

ToDictionaryAsync<TSource,TKey>(IQueryable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)

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

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

Asynchronously creates a HashSet<T> from an IQueryable<T> by enumerating it asynchronously.

ToHashSetAsync<TSource>(IQueryable<TSource>, IEqualityComparer<TSource>, CancellationToken)

Asynchronously creates a HashSet<T> from an IQueryable<T> by enumerating it asynchronously.

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

Asynchronously creates a List<T> from an IQueryable<T> by enumerating it asynchronously.

ToQueryString(IQueryable)

Generates a string representation of the query used. This string may not be suitable for direct execution and is intended only for use in debugging.

Applies to