DbContext.Set 方法

定義

多載

Set<TEntity>()

DbSet<TEntity>建立可用來查詢和儲存 實例的 TEntity

Set<TEntity>(String)

建立共用型別實體類型的 , DbSet<TEntity> 可用來查詢和儲存 的 TEntity 實例。

Set<TEntity>()

DbSet<TEntity>建立可用來查詢和儲存 實例的 TEntity

public virtual Microsoft.EntityFrameworkCore.DbSet<TEntity> Set<TEntity> () where TEntity : class;
abstract member Set : unit -> Microsoft.EntityFrameworkCore.DbSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.Set : unit -> Microsoft.EntityFrameworkCore.DbSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function Set(Of TEntity As Class) () As DbSet(Of TEntity)

類型參數

TEntity

應該傳回集合的實體型別。

傳回

指定實體類型的集合。

備註

Entity Framework Core 不支援在相同的 DbCoNtext 實例上執行多個平行作業。 這包括平行執行非同步查詢,以及明確同時使用多個執行緒。 因此,請一律立即等候非同步呼叫,或針對平行執行的作業使用個別的 DbCoNtext 實例。 如需詳細資訊和範例 ,請參閱避免 DbCoNtext 執行緒問題

如需詳細資訊和範例,請參閱 使用 EF Core 查詢資料變更追蹤

適用於

Set<TEntity>(String)

建立共用型別實體類型的 , DbSet<TEntity> 可用來查詢和儲存 的 TEntity 實例。

public virtual Microsoft.EntityFrameworkCore.DbSet<TEntity> Set<TEntity> (string name) where TEntity : class;
abstract member Set : string -> Microsoft.EntityFrameworkCore.DbSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.Set : string -> Microsoft.EntityFrameworkCore.DbSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function Set(Of TEntity As Class) (name As String) As DbSet(Of TEntity)

類型參數

TEntity

應該傳回集合的實體型別。

參數

name
String

要使用的共用類型實體類型名稱。

傳回

指定實體類型的集合。

備註

共用類型實體類型通常用於多對多關聯性中的聯結實體。

如需詳細資訊和範例,請參閱 使用 EF Core 查詢資料變更追蹤共用實體類型

適用於