Share via


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 クラスのトピックを参照してください。

参照

参照

DbContext クラス

Set オーバーロード

System.Data.Entity 名前空間