DbContext.Set 方法 (Type)
[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]
傳回非泛型 DbSet 執行個體來存取內容中給定類型的實體和基礎存放區。
命名空間: System.Data.Entity
組件: EntityFramework (在 EntityFramework.dll 中)
語法
'宣告
<SuppressMessageAttribute("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId := "Set")> _
Public Overridable Function Set ( _
entityType As Type _
) As DbSet
'用途
Dim instance As DbContext
Dim entityType As Type
Dim returnValue As DbSet
returnValue = instance.Set(entityType)
[SuppressMessageAttribute("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Set")]
public virtual DbSet Set(
Type entityType
)
[SuppressMessageAttribute(L"Microsoft.Naming", L"CA1716:IdentifiersShouldNotMatchKeywords", MessageId = L"Set")]
public:
virtual DbSet^ Set(
Type^ entityType
)
[<SuppressMessageAttribute("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Set")>]
abstract Set :
entityType:Type -> DbSet
[<SuppressMessageAttribute("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Set")>]
override Set :
entityType:Type -> DbSet
public function Set(
entityType : Type
) : DbSet
參數
- entityType
類型:System.Type
應該傳回集合的實體類型。
傳回值
類型:System.Data.Entity.DbSet
給定實體類型的集合。
備註
請注意,Entity Framework 要求此方法在每次針對給定內容執行個體和實體類型呼叫時傳回相同的執行個體。 同時,Set(Type) 方法傳回的泛型 DbSet<TEntity> 必須包裝相同的基礎查詢和實體集。 如果是針對單元測試建立測試複本以外的任何項目覆寫此方法,則必須維護這些非變異項。 如需其他詳細資訊,請參閱 DbSet 類別。