語言

DbSet<TEntity> 類別

定義

DbSet<TEntity> A 可用來查詢並儲存 的TEntity實例。 對 的 DbSet<TEntity> LINQ 查詢會被轉譯成對資料庫的查詢。

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
[System.Runtime.CompilerServices.Nullable(0)]
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
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>
[<System.Runtime.CompilerServices.Nullable(0)>]
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
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 IEnumerable(Of TEntity), IInfrastructure(Of IServiceProvider), IListSource, 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)

類型參數

TEntity

此集合所操作的實體類型。

繼承
DbSet<TEntity>
衍生
屬性
實作
IInfrastructure<IServiceProvider> Microsoft.EntityFrameworkCore.Query.Internal.IAsyncEnumerableAccessor<TEntity> IEnumerable<T> IEnumerable<TEntity> IEnumerable IQueryable IQueryable<TEntity> IListSource IAsyncEnumerable<TEntity>

備註

對 的 DbSet<TEntity> LINQ 查詢結果將包含從資料庫回傳的結果,且可能不反映上下文中未持久化至資料庫的變更。 例如,結果不會包含新加入的實體,且可能仍包含標記為刪除的實體。

根據所使用的資料庫,LINQ 查詢 DbSet<TEntity> 的某些部分可能會在記憶體中評估,而非轉譯成資料庫查詢。

DbSet<TEntity> 物件通常是從 DbSet<TEntity> 導出 DbContext 的屬性或 Set<TEntity>() 方法中取得的。

Entity Framework Core 不支援在同一 DbContext 執行個體上執行多個平行作業。 這包括平行執行非同步查詢,以及明確同時使用多個執行緒。 因此,務必立即等待非同步呼叫,或使用獨立的 DbContext 實例來執行平行執行的操作。 更多資訊與範例請參見 「避免 DbContext 執行緒問題 」。

更多資訊與範例請參閱 DbContext 生命週期、配置與初始化、使用 EF Core 查詢資料,以及 變更追蹤 。

建構函式

名稱 Description
DbSet<TEntity>()

DbSet<TEntity> A 可用來查詢並儲存 的TEntity實例。 對 的 DbSet<TEntity> LINQ 查詢會被轉譯成對資料庫的查詢。

屬性

名稱 Description
EntityType

IEntityType與此集合相關的元資料。

Local

獲得 LocalView<TEntity> 代表本集合中所有新增、未變更及修改實體的局部視圖。

方法

名稱 Description
Add(TEntity)

開始追蹤指定實體及尚未被追蹤 Added 的其他可達實體,使其在呼叫時 SaveChanges() 插入資料庫。

AddAsync(TEntity, CancellationToken)

開始追蹤指定實體及尚未被追蹤 Added 的其他可達實體,使其在呼叫時 SaveChanges() 插入資料庫。

AddRange(IEnumerable<TEntity>)

開始追蹤給定實體及尚未被追蹤的其他可達實體,使其 Added 在呼叫時 SaveChanges() 會入資料庫。

AddRange(TEntity[])

開始追蹤給定實體及尚未被追蹤的其他可達實體,使其 Added 在呼叫時 SaveChanges() 會入資料庫。

AddRangeAsync(IEnumerable<TEntity>, CancellationToken)

開始追蹤給定實體及尚未被追蹤的其他可達實體,使其 Added 在呼叫時 SaveChanges() 會入資料庫。

AddRangeAsync(TEntity[])

開始追蹤給定實體及尚未被追蹤的其他可達實體,使其 Added 在呼叫時 SaveChanges() 會入資料庫。

AsAsyncEnumerable()

回傳此物件,類型為 IAsyncEnumerable<T>。

AsQueryable()

回傳此物件,類型為 IQueryable<T>。

Attach(TEntity)

開始追蹤該實體及其可從該實體存取的條目,預設使用 Unchanged 該狀態,但若使用不同狀態,請見下文。

AttachRange(IEnumerable<TEntity>)

開始追蹤給定實體及可從該實體存取的條目,預設使用 Unchanged 該狀態,但下文說明使用不同狀態的情況。

AttachRange(TEntity[])

開始追蹤給定實體及可從該實體存取的條目,預設使用 Unchanged 該狀態,但下文說明使用不同狀態的情況。

Entry(TEntity)

會為該實體取得一個。EntityEntry<TEntity> 該條目提供實體的變更追蹤資訊及營運權限。

Find(Object[])

尋找具有給定主鍵值的實體。 如果上下文追蹤的是具有相同主鍵值的實體,則該實體會立即回傳,無需向資料庫提出請求。 否則,會向資料庫查詢具有給定主鍵值的實體,若找到該實體,會附加到上下文中並回傳。 若未找到實體,則回傳 null。

FindAsync(Object[], CancellationToken)

尋找具有給定主鍵值的實體。 如果上下文追蹤的是具有相同主鍵值的實體,則該實體會立即回傳,無需向資料庫提出請求。 否則,會向資料庫查詢具有給定主鍵值的實體,若找到該實體,會附加到上下文中並回傳。 若未找到實體,則回傳 null。

FindAsync(Object[])

尋找具有給定主鍵值的實體。 如果上下文追蹤的是具有相同主鍵值的實體,則該實體會立即回傳,無需向資料庫提出請求。 否則,會向資料庫查詢具有給定主鍵值的實體,若找到該實體,會附加到上下文中並回傳。 若未找到實體,則回傳 null。

GetAsyncEnumerator(CancellationToken)

回傳 , IAsyncEnumerator<T> 當被列舉時,會對資料庫進行非同步查詢。

Remove(TEntity)

開始追蹤該州的實體 Deleted ,使其在呼叫時 SaveChanges() 從資料庫中移除。

RemoveRange(IEnumerable<TEntity>)

開始追蹤該狀態內 Deleted 的實體,使其在呼叫時 SaveChanges() 會從資料庫中移除。

RemoveRange(TEntity[])

開始追蹤該狀態內 Deleted 的實體,使其在呼叫時 SaveChanges() 會從資料庫中移除。

Update(TEntity)

開始追蹤該實體及其可從該實體存取的條目,預設使用 Modified 該狀態,但若使用不同狀態,請見下文。

UpdateRange(IEnumerable<TEntity>)

開始追蹤給定實體及可從該實體存取的條目,預設使用 Modified 該狀態,但下文說明使用不同狀態的情況。

UpdateRange(TEntity[])

開始追蹤給定實體及可從該實體存取的條目,預設使用 Modified 該狀態,但下文說明使用不同狀態的情況。

明確介面實作

名稱 Description
IAsyncEnumerable<TEntity>.GetAsyncEnumerator(CancellationToken)

回傳 , IAsyncEnumerator<T> 當被列舉時,會對資料庫進行非同步查詢。

IAsyncEnumerableAccessor<TEntity>.AsyncEnumerable

回傳 , IAsyncEnumerable<T> 當被列舉時,會對資料庫進行非同步執行查詢。

IEnumerable.GetEnumerator()

回傳 , IEnumerator 當列舉時,會對資料庫執行查詢,載入資料庫中的所有實體。

IEnumerable<TEntity>.GetEnumerator()

回傳 , IEnumerator<T> 當列舉時,會對資料庫執行查詢,載入資料庫中的所有實體。

IInfrastructure<IServiceProvider>.Instance

取得用於解決服務的範圍 IServiceProvider 。

IListSource.ContainsListCollection

會取得一個值,表示該集合是否為 System.Collections.IList 物件的集合。 一律傳回 false。

IListSource.GetList()

當資料綁定框架嘗試直接 DbSet<TEntity>對資料綁定時,會呼叫此方法。

IQueryable.ElementType

獲得IQueryable元素類型。

IQueryable.Expression

能得到IQueryable的LINQ表達式。

IQueryable.Provider

取得IQueryable的提供者。

擴充方法

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

非同步判斷序列中的所有元素是否滿足某一條件。

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

非同步判斷序列是否包含任何元素。

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

非同步判斷序列中任一元素是否滿足某條件。

AsAsyncEnumerable<TSource>(IQueryable<TSource>)

回傳 和 IAsyncEnumerable<T> ,可非同步列舉。

AsNoTracking<TEntity>(IQueryable<TEntity>)

變更追蹤器不會追蹤從 LINQ 查詢回傳的任何實體。 若實體實例被修改,變更追蹤器不會偵測到,且 SaveChanges() 這些變更不會持久化到資料庫中。

AsNoTrackingWithIdentityResolution<TEntity>(IQueryable<TEntity>)

變更追蹤器不會追蹤從 LINQ 查詢回傳的任何實體。 若實體實例被修改,變更追蹤器不會偵測到,且 SaveChanges() 這些變更不會持久化到資料庫中。

AsSingleQuery<TEntity>(IQueryable<TEntity>)

回傳一個新查詢,該查詢設定為將查詢結果中的集合匯入單一資料庫查詢。

AsSplitQuery<TEntity>(IQueryable<TEntity>)

回傳一個新查詢,並設定為透過獨立資料庫查詢載入查詢結果中的集合。

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

會回傳一個新查詢,變更追蹤器會根據「追蹤」參數的值,對所有回傳的實體都會追蹤變更,或不會追蹤。 在追蹤時,任何對實體實例的修改都會被偵測並持續保存到資料庫中。SaveChanges() 當不追蹤時,若實體實例被修改,變更追蹤器不會偵測到,且 SaveChanges() 這些變更不會持久化到資料庫中。

AsTracking<TEntity>(IQueryable<TEntity>)

回傳一個新查詢,變更追蹤器會追蹤所有回傳實體的變更。 任何對實體實例的修改都會被偵測到,並在 期間持續存在資料庫 SaveChanges()。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步計算透過在輸入序列中每個元素上呼叫投影函數所得到的數值序列的平均值。

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

非同步地利用預設的等號比較器判斷序列是否包含特定元素。

ContainsTable<T,TKey>(DbSet<T>, String, Expression<Func<T,Object>>, String, Nullable<Int32>)

使用 SQL Server CONTAINSTABLE 函式查詢全文索引。

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

非同步回傳序列中的元素數量。

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

非同步回傳序列中滿足條件的元素數量。

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

如果已開啟代理建立,會為某個實體類型建立代理實例。

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

如果已開啟代理建立,會為某個實體類型建立代理實例。

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

非同步回傳序列中指定索引的元素。

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

非同步回傳序列中指定索引的元素,若索引超出範圍則回傳預設值。

ExecuteDelete<TSource>(IQueryable<TSource>)

刪除所有與 LINQ 查詢相符實體實例的資料庫列。

ExecuteDelete<TSource>(IQueryable<TSource>)

刪除所有與 LINQ 查詢相符實體實例的資料庫列。

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

非同步刪除與 LINQ 查詢相符的實體實例的資料庫列。

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

非同步刪除與 LINQ 查詢相符的實體實例的資料庫列。

ExecuteUpdate<TSource>(IQueryable<TSource>, Action<UpdateSettersBuilder<TSource>>)

更新所有與資料庫 LINQ 查詢相符實體實例的資料庫資料列。

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

更新所有與資料庫 LINQ 查詢相符實體實例的資料庫資料列。

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

更新所有與資料庫 LINQ 查詢相符實體實例的資料庫資料列。

ExecuteUpdateAsync<TSource>(IQueryable<TSource>, Action<UpdateSettersBuilder<TSource>>, CancellationToken)

非同步更新與資料庫 LINQ 查詢相符實體實例的資料庫列。

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

非同步更新與資料庫 LINQ 查詢相符實體實例的資料庫列。

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

非同步更新與資料庫 LINQ 查詢相符實體實例的資料庫列。

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

非同步回傳序列的第一個元素。

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

非同步回傳滿足特定條件的序列中第一個元素。

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

非同步回傳序列的第一個元素,若序列中沒有元素則回傳預設值。

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

非同步回傳序列中第一個符合指定條件的元素,若未找到該元素則回傳預設值。

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

非同步列舉查詢結果,並對每個元素執行指定動作。

FreeTextTable<T,TKey>(DbSet<T>, String, Expression<Func<T,Object>>, String, Nullable<Int32>)

使用 SQL Server FREETEXTTABLE 函式查詢全文索引。

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

根據一個插值字串(代表 SQL 查詢)建立一個 LINQ 查詢。

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

根據一個插值字串(代表 SQL 查詢)建立一個 LINQ 查詢。

FromSql<TEntity>(IQueryable<TEntity>, FormattableString)
已淘汰.

根據一個插值字串(代表 SQL 查詢)建立一個 LINQ 查詢。

如果資料庫提供者支援在提供的 SQL 上撰寫,你可以使用 LINQ 運算子 - context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name)在原始 SQL 查詢上進行組合。

和任何接受 SQL 的 API 一樣,必須對使用者輸入進行參數化,以防止 SQL 注入攻擊。 你可以在 SQL 查詢字串中加入插值參數的佔位符。 你提供的任何插值參數值都會自動轉換成 DbParameter - context.Blogs.FromSql($"SELECT * FROM [dbo].[SearchBlogs]({userSuppliedSearchTerm})")。

FromSql<TEntity>(IQueryable<TEntity>, RawSqlString, Object[])
已淘汰.

根據原始 SQL 查詢建立 LINQ 查詢。

如果資料庫提供者支援在提供的 SQL 上撰寫,你可以使用 LINQ 運算子 - context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name)在原始 SQL 查詢上進行組合。

和任何接受 SQL 的 API 一樣,必須對使用者輸入進行參數化,以防止 SQL 注入攻擊。 你可以在 SQL 查詢字串中加入參數佔位符,然後以參數值作為額外參數。 你提供的任何參數值都會自動轉換成 DbParameter - context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm)。

此超載同時接受 DbParameter 實例作為參數值。 這讓你可以在 SQL 查詢字串中使用命名參數—— context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({@searchTerm})", new SqlParameter("@searchTerm", userSuppliedSearchTerm))

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

根據原始 SQL 查詢建立 LINQ 查詢。

如果資料庫提供者支援在提供的 SQL 上撰寫,你可以使用 LINQ 運算子 - context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name)在原始 SQL 查詢上進行組合。

和任何接受 SQL 的 API 一樣,必須對使用者輸入進行參數化,以防止 SQL 注入攻擊。 你可以在 SQL 查詢字串中加入參數佔位符,然後以參數值作為額外參數。 你提供的任何參數值都會自動轉換成 DbParameter - context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm)。

你也可以建構一個 DbParameter,並以參數值提供給 。 這讓你可以在 SQL 查詢字串中使用命名參數—— context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({@searchTerm})", new SqlParameter("@searchTerm", userSuppliedSearchTerm))

FromSqlInterpolated<TEntity>(DbSet<TEntity>, FormattableString)
已淘汰.

根據一個插值字串(代表 SQL 查詢)建立一個 LINQ 查詢。

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

根據原始 SQL 查詢建立 LINQ 查詢。

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

根據原始 SQL 查詢建立 LINQ 查詢。

GetInfrastructure<T>(IInfrastructure<T>)

從一個被隱藏的屬性中取得價值 IInfrastructure<T>。

此方法通常由資料庫提供者(及其他擴充)使用。 它通常不被用於應用程式程式碼中。

IgnoreAutoIncludes<TEntity>(IQueryable<TEntity>)

規定目前的 Entity Framework LINQ 查詢不應套用任何模型層級的 eager loaded 導覽。

IgnoreQueryFilters<TEntity>(IQueryable<TEntity>, IReadOnlyCollection<String>)

規定目前的實體框架 LINQ 查詢不應套用任何模型層級的實體查詢過濾器。

IgnoreQueryFilters<TEntity>(IQueryable<TEntity>)

規定目前的實體框架 LINQ 查詢不應套用任何模型層級的實體查詢過濾器。

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

指定相關實體,包含在查詢結果中。 要包含的導航屬性會從被查詢TEntity的實體類型()開始指定。 如果你想根據所包含型別的導航屬性加入更多類型,請在此呼叫後串接呼叫至 ThenInclude<TEntity,TPreviousProperty,TProperty>(IIncludableQueryable<TEntity, IEnumerable<TPreviousProperty>>, Expression<Func<TPreviousProperty, TProperty>>) 。

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

指定相關實體,包含在查詢結果中。 要包含的導航屬性會從被查詢TEntity的實體類型()開始指定。 其他需包含的導航屬性可附加,並以 '.' 字元分隔。

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

非同步回傳序列的最後一個元素。

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

非同步回傳序列中滿足特定條件的最後一個元素。

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

非同步回傳序列的最後一個元素,若序列中無元素則回傳預設值。

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

非同步回傳序列中滿足特定條件的最後一個元素,若找不到該元素則回傳預設值。

Load<TSource>(IQueryable<TSource>)

列舉查詢。 使用實體框架時,查詢結果會被載入到相關上下文中。 這相當於呼叫 ToList,然後丟棄清單(但沒有實際建立清單的額外負擔)。

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

非同步列舉查詢。 使用實體框架時,查詢結果會被載入到相關上下文中。 這相當於呼叫 ToList,然後丟棄清單(但沒有實際建立清單的額外負擔)。

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

非同步回傳代表序列中元素總數的 a Int64 。

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

非同步回傳 a Int64 ,代表序列中滿足條件的元素數量。

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

非同步地對序列中的每個元素呼叫投影函數,並回傳最大結果值。

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

非同步回傳序列的最大值。

MaxByAsync<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, CancellationToken)

非同步回傳根據指定的鍵選擇函式,在通用中 IQueryable<T> 最大值。

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

非同步地對序列中的每個元素呼叫投影函數,並回傳最小結果值。

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

非同步回傳序列的最小值。

MinByAsync<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, CancellationToken)

非同步回傳根據指定的鍵選擇函式,將通用的 IQueryable<T> 最小值回傳。

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

非同步回傳序列中唯一的元素,若序列中沒有恰好一個元素則拋出例外。

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

非同步回傳序列中唯一符合特定條件的元素,若存在多個此類元素則拋出例外。

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

非同步回傳序列中唯一的元素,若序列為空則回傳預設值;此方法若序列中有多個元素,會拋出例外。

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

非同步回傳序列中唯一符合指定條件的元素,若不存在該元素則回傳預設值;此方法若有多個元素符合條件,則拋出例外。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

非同步計算透過呼叫投影函數在輸入序列中每個元素上所得到的數值序列總和。

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

在與 EF LINQ 查詢相關的標籤集合中新增一個標籤。 標籤是查詢註解,能在查詢流程的不同點提供上下文追蹤資訊。

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

在與 EF LINQ 查詢相關的標籤集合中新增一個標籤,包含來源檔名及方法呼叫的行,能在查詢流程的不同階段提供上下文追蹤資訊。

TemporalAll<TEntity>(DbSet<TEntity>)

對給定的資料庫集套用時間「全部」操作,回傳所有實體的歷史版本及其當前狀態。

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

對給定的資料庫集合套用時間「AsOf」操作,僅回傳資料庫中某一時間點存在的元素。

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

對給定的資料庫集套用時間「中間」操作,僅回傳資料庫中兩個時間點之間存在的元素。

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

對給定的資料庫集合套用時間「ContainedIn」操作,僅回傳資料庫中兩個時間點之間存在的元素。

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

對給定的資料庫集套用時間上的「FromTo」操作,僅回傳資料庫中兩個時間點之間存在的元素。

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

非同步地從 中 IQueryable<T> 建立陣列,方法是透過非同步枚舉它。

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

透過非同步列舉,依照指定的鍵選擇器與元素選擇函式,從 建立 a Dictionary<TKey,TValue>IQueryable<T> 。

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

透過非同步列舉,依照指定的鍵選擇函數、比較器及元素選擇函式,從 和 IQueryable<T> 建立 aDictionary<TKey,TValue>。

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

透過非同步列舉,依照指定的鍵選擇函式從 中IQueryable<T>建立 aDictionary<TKey,TValue>。

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

透過非同步列舉,根據指定的金鑰選擇函式與比較器,從 和 IQueryable<T> 建立 。Dictionary<TKey,TValue>

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

非同步地從 中IQueryable<T>建立 aHashSet<T>,方法是透過非同步列舉它。

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

非同步地從 中IQueryable<T>建立 aHashSet<T>,方法是透過非同步列舉它。

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

非同步地從 中IQueryable<T>建立 aList<T>,方法是透過非同步列舉它。

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

允許透過重複執行相同查詢來分頁查詢結果,傳遞續寫標記以檢索結果集的連續頁面,並指定每頁最大結果數量。

VectorSearch<T,TVector>(DbSet<T>, Expression<Func<T,TVector>>, TVector, String)

使用 SQL Server VECTOR_SEARCH() 函式搜尋與特定查詢向量相似的向量。

WithApproximate<T>(IQueryable<T>)

啟用向量搜尋查詢的近似最近鄰(ANN)搜尋。 這會導致 WITH APPROXIMATE 加入 SQL TOP 子句,指示 SQL Server 使用向量索引以提升效能。

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

指定用於查詢的分割鍵。 當使用基於分割金鑰提供權限的資源憑證時,必須如此操作,

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

指定用於查詢的分割鍵。 當使用基於分割金鑰提供權限的資源憑證時,必須如此操作,

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

指定用於查詢的分割鍵。 當使用基於分割金鑰提供權限的資源憑證時,必須如此操作,

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

指定用於查詢的分割鍵。 當使用基於分割金鑰提供權限的資源憑證時,必須如此操作,

適用於