Sdílet prostřednictvím


DbSet<TEntity> Class

Definition

A DbSet<TEntity> can be used to query and save instances of TEntity. LINQ queries against a DbSet<TEntity> will be translated into queries against the database.

public abstract class DbSet<TEntity> : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider>, Microsoft.EntityFrameworkCore.Query.Internal.IAsyncEnumerableAccessor<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.Linq.IQueryable<TEntity> where TEntity : class
public abstract class DbSet<TEntity> : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider>, Microsoft.EntityFrameworkCore.Query.Internal.IAsyncEnumerableAccessor<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource, System.Linq.IQueryable<TEntity> where TEntity : class
public abstract class DbSet<TEntity> : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider>, System.Collections.Generic.IAsyncEnumerable<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource, System.Linq.IQueryable<TEntity> where TEntity : class
public abstract class DbSet<TEntity> : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider>, System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource, System.Linq.IQueryable<TEntity> where TEntity : class
type DbSet<'Entity (requires 'Entity : null)> = class
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable
    interface IAsyncEnumerableAccessor<'Entity (requires 'Entity : null)>
    interface IInfrastructure<IServiceProvider>
type DbSet<'Entity (requires 'Entity : null)> = class
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable
    interface IAsyncEnumerableAccessor<'Entity (requires 'Entity : null)>
    interface IInfrastructure<IServiceProvider>
    interface IListSource
type DbSet<'Entity (requires 'Entity : null)> = class
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable
    interface IAsyncEnumerable<'Entity (requires 'Entity : null)>
    interface IInfrastructure<IServiceProvider>
    interface IListSource
type DbSet<'Entity (requires 'Entity : null)> = class
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable
    interface IInfrastructure<IServiceProvider>
    interface IListSource
Public MustInherit Class DbSet(Of TEntity)
Implements IAsyncEnumerableAccessor(Of TEntity), IEnumerable(Of TEntity), IInfrastructure(Of IServiceProvider), IQueryable(Of TEntity)
Public MustInherit Class DbSet(Of TEntity)
Implements IAsyncEnumerableAccessor(Of TEntity), IEnumerable(Of TEntity), IInfrastructure(Of IServiceProvider), IListSource, IQueryable(Of TEntity)
Public MustInherit Class DbSet(Of TEntity)
Implements IAsyncEnumerable(Of TEntity), IEnumerable(Of TEntity), IInfrastructure(Of IServiceProvider), IListSource, IQueryable(Of TEntity)
Public MustInherit Class DbSet(Of TEntity)
Implements IEnumerable(Of TEntity), IInfrastructure(Of IServiceProvider), IListSource, IQueryable(Of TEntity)

Type Parameters

TEntity

The type of entity being operated on by this set.

Inheritance
DbSet<TEntity>
Derived
Implements
IInfrastructure<IServiceProvider> Microsoft.EntityFrameworkCore.Query.Internal.IAsyncEnumerableAccessor<TEntity> IEnumerable<T> IEnumerable<TEntity> IEnumerable IQueryable IQueryable<TEntity> IListSource IAsyncEnumerable<TEntity>

Remarks

The results of a LINQ query against a DbSet<TEntity> will contain the results returned from the database and may not reflect changes made in the context that have not been persisted to the database. For example, the results will not contain newly added entities and may still contain entities that are marked for deletion.

Depending on the database being used, some parts of a LINQ query against a DbSet<TEntity> may be evaluated in memory rather than being translated into a database query.

DbSet<TEntity> objects are usually obtained from a DbSet<TEntity> property on a derived DbContext or from the Set<TEntity>() method.

Entity Framework Core does not support multiple parallel operations being run on the same DbContext instance. This includes both parallel execution of async queries and any explicit concurrent use from multiple threads. Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute in parallel. See Avoiding DbContext threading issues for more information and examples.

See DbContext lifetime, configuration, and initialization, Querying data with EF Core, and Changing tracking for more information and examples.

Constructors

DbSet<TEntity>()

Properties

EntityType

The IEntityType metadata associated with this set.

Local

Gets a LocalView<TEntity> that represents a local view of all Added, Unchanged, and Modified entities in this set.

Methods

Add(TEntity)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddAsync(TEntity, CancellationToken)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRange(IEnumerable<TEntity>)

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRange(TEntity[])

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRangeAsync(IEnumerable<TEntity>, CancellationToken)

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRangeAsync(TEntity[])

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AsAsyncEnumerable()

Returns this object typed as IAsyncEnumerable<T>.

AsQueryable()

Returns this object typed as IQueryable<T>.

Attach(TEntity)

Begins tracking the given entity and entries reachable from the given entity using the Unchanged state by default, but see below for cases when a different state will be used.

AttachRange(IEnumerable<TEntity>)

Begins tracking the given entities and entries reachable from the given entities using the Unchanged state by default, but see below for cases when a different state will be used.

AttachRange(TEntity[])

Begins tracking the given entities and entries reachable from the given entities using the Unchanged state by default, but see below for cases when a different state will be used.

Entry(TEntity)

Gets an EntityEntry<TEntity> for the given entity. The entry provides access to change tracking information and operations for the entity.

Find(Object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

FindAsync(Object[], CancellationToken)

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

FindAsync(Object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

GetAsyncEnumerator(CancellationToken)

Returns an IAsyncEnumerator<T> which when enumerated will asynchronously execute a query against the database.

Remove(TEntity)

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

RemoveRange(IEnumerable<TEntity>)

Begins tracking the given entities in the Deleted state such that they will be removed from the database when SaveChanges() is called.

RemoveRange(TEntity[])

Begins tracking the given entities in the Deleted state such that they will be removed from the database when SaveChanges() is called.

Update(TEntity)

Begins tracking the given entity and entries reachable from the given entity using the Modified state by default, but see below for cases when a different state will be used.

UpdateRange(IEnumerable<TEntity>)

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

UpdateRange(TEntity[])

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

Explicit Interface Implementations

IAsyncEnumerable<TEntity>.GetAsyncEnumerator(CancellationToken)

Returns an IAsyncEnumerator<T> which when enumerated will asynchronously execute a query against the database.

IAsyncEnumerableAccessor<TEntity>.AsyncEnumerable

Returns an IAsyncEnumerable<T> which when enumerated will asynchronously execute the query against the database.

IEnumerable.GetEnumerator()

Returns an IEnumerator which when enumerated will execute a query against the database to load all entities from the database.

IEnumerable<TEntity>.GetEnumerator()

Returns an IEnumerator<T> which when enumerated will execute a query against the database to load all entities from the database.

IInfrastructure<IServiceProvider>.Instance

Gets the scoped IServiceProvider being used to resolve services.

IListSource.ContainsListCollection

Gets a value indicating whether the collection is a collection of System.Collections.IList objects. Always returns false.

IListSource.GetList()

This method is called by data binding frameworks when attempting to data bind directly to a DbSet<TEntity>.

IQueryable.ElementType

Gets the IQueryable element type.

IQueryable.Expression

Gets the IQueryable LINQ Expression.

IQueryable.Provider

Gets the IQueryable provider.

Extension Methods

FromSql<TEntity>(DbSet<TEntity>, FormattableString)

Creates a LINQ query based on an interpolated string representing a SQL query.

FromSqlRaw<TEntity>(DbSet<TEntity>, String, Object[])

Creates a LINQ query based on a raw SQL query.

ToPageAsync<TSource>(IQueryable<TSource>, Int32, String, Nullable<Int32>, CancellationToken)

Allows paginating through query results by repeatedly executing the same query, passing continuation tokens to retrieve successive pages of the result set, and specifying the maximum number of results per page.

WithPartitionKey<TEntity>(IQueryable<TEntity>, Object, Object, Object)

Specify the partition key for partition used for the query. Required when using a resource token that provides permission based on a partition key for authentication,

WithPartitionKey<TEntity>(IQueryable<TEntity>, Object, Object)

Specify the partition key for partition used for the query. Required when using a resource token that provides permission based on a partition key for authentication,

WithPartitionKey<TEntity>(IQueryable<TEntity>, Object)

Specify the partition key for partition used for the query. Required when using a resource token that provides permission based on a partition key for authentication,

WithPartitionKey<TEntity>(IQueryable<TEntity>, String)

Specify the partition key for partition used for the query. Required when using a resource token that provides permission based on a partition key for authentication,

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>, Expression<Func<TSource,Boolean>>, CancellationToken)

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

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

Asynchronously determines whether a sequence contains any elements.

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<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>, Expression<Func<TSource,Boolean>>, CancellationToken)

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

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

Asynchronously returns the number of elements in a sequence.

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>, Expression<Func<TSource,Boolean>>, CancellationToken)

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

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

Asynchronously returns the first element of a sequence.

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.

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

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

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>(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.

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.

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

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

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

Asynchronously returns the last element of a sequence.

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.

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

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

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>, Expression<Func<TSource,Boolean>>, CancellationToken)

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

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

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

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

Asynchronously returns the maximum value of a sequence.

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.

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

Asynchronously returns the minimum 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.

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.

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.

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.

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.

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.

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

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

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.

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,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,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.

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

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

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

GetInfrastructure<T>(IInfrastructure<T>)

Gets the value from a property that is being hidden using IInfrastructure<T>.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

CreateProxy<TEntity>(DbSet<TEntity>, Action<TEntity>, Object[])

Creates a proxy instance for an entity type if proxy creation has been turned on.

CreateProxy<TEntity>(DbSet<TEntity>, Object[])

Creates a proxy instance for an entity type if proxy creation has been turned on.

AsSingleQuery<TEntity>(IQueryable<TEntity>)

Returns a new query which is configured to load the collections in the query results in a single database query.

AsSplitQuery<TEntity>(IQueryable<TEntity>)

Returns a new query which is configured to load the collections in the query results through separate database queries.

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.

FromSql<TEntity>(DbSet<TEntity>, FormattableString)

Creates a LINQ query based on an interpolated string representing a SQL query.

FromSql<TEntity>(IQueryable<TEntity>, RawSqlString, Object[])
Obsolete.

Creates a LINQ query based on a raw SQL query.

If the database provider supports composing on the supplied SQL, you can compose on top of the raw SQL query using LINQ operators - context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name).

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter - context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm).

This overload also accepts DbParameter instances as parameter values. This allows you to use named parameters in the SQL query string - context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({@searchTerm})", new SqlParameter("@searchTerm", userSuppliedSearchTerm))

FromSql<TEntity>(IQueryable<TEntity>, FormattableString)
Obsolete.

Creates a LINQ query based on an interpolated string representing a SQL query.

If the database provider supports composing on the supplied SQL, you can compose on top of the raw SQL query using LINQ operators - context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name).

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include interpolated parameter place holders in the SQL query string. Any interpolated parameter values you supply will automatically be converted to a DbParameter - context.Blogs.FromSql($"SELECT * FROM [dbo].[SearchBlogs]({userSuppliedSearchTerm})").

FromSql<TEntity>(IQueryable<TEntity>, String, Object[])

Creates a LINQ query based on a raw SQL query.

If the database provider supports composing on the supplied SQL, you can compose on top of the raw SQL query using LINQ operators - context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name).

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter - context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm).

You can also construct a DbParameter and supply it to as a parameter value. This allows you to use named parameters in the SQL query string - context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({@searchTerm})", new SqlParameter("@searchTerm", userSuppliedSearchTerm))

FromSqlInterpolated<TEntity>(DbSet<TEntity>, FormattableString)

Creates a LINQ query based on an interpolated string representing a SQL query.

FromSqlRaw<TEntity>(DbSet<TEntity>, String, Object[])

Creates a LINQ query based on a raw SQL query.

TemporalAll<TEntity>(DbSet<TEntity>)

Applies temporal 'All' operation on the given DbSet, which returns all historical versions of the entities as well as their current state.

TemporalAsOf<TEntity>(DbSet<TEntity>, DateTime)

Applies temporal 'AsOf' operation on the given DbSet, which only returns elements that were present in the database at a given point in time.

TemporalBetween<TEntity>(DbSet<TEntity>, DateTime, DateTime)

Applies temporal 'Between' operation on the given DbSet, which only returns elements that were present in the database between two points in time.

TemporalContainedIn<TEntity>(DbSet<TEntity>, DateTime, DateTime)

Applies temporal 'ContainedIn' operation on the given DbSet, which only returns elements that were present in the database between two points in time.

TemporalFromTo<TEntity>(DbSet<TEntity>, DateTime, DateTime)

Applies temporal 'FromTo' operation on the given DbSet, which only returns elements that were present in the database between two points in time.

Applies to