DbContext.Set, méthode (Type)
[Cette page concerne Entity Framework version 6. La dernière version est disponible sous le nom de package 'Entity Framework' NuGet. Pour plus d'informations sur Entity Framework, consultez msdn.com/data/ef.]
Retourne une instance DbSet non générique pour l'accès aux entités du type donné dans le contexte et le magasin sous-jacent.
Espace de noms : System.Data.Entity
Assembly : EntityFramework (dans EntityFramework.dll)
Syntaxe
'Déclaration
<SuppressMessageAttribute("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId := "Set")> _
Public Overridable Function Set ( _
entityType As Type _
) As DbSet
'Utilisation
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
Paramètres
- entityType
Type : System.Type
Type d'entité pour lequel un ensemble doit être retourné.
Valeur de retour
Type : System.Data.Entity.DbSet
Jeu pour le type d'entité donné.
Notes
Notez que, dans Entity Framework, cette méthode doit retourner la même instance chaque fois qu'elle est appelée pour une instance de contexte et un type d'entité donnés. De plus, le DbSet<TEntity> générique retourné par la méthode Set(Type) doit encapsuler la même requête sous-jacente et le même jeu d'entités. Ces invariants doivent être conservés si cette méthode est remplacée dans un autre but que la création de doubles tests pour tester les unités. Pour plus d'informations, consultez la classe DbSet.