DbContext.Set Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Set(Type) |
Returns a non-generic DbSet instance for access to entities of the given type in the context and the underlying store. |
Set<TEntity>() |
Returns a DbSet<TEntity> instance for access to entities of the given type in the context and the underlying store. |
Set(Type)
Returns a non-generic DbSet instance for access to entities of the given type in the context and the underlying store.
public virtual System.Data.Entity.DbSet Set (Type entityType);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId="Set")]
public virtual System.Data.Entity.DbSet Set (Type entityType);
abstract member Set : Type -> System.Data.Entity.DbSet
override this.Set : Type -> System.Data.Entity.DbSet
Public Overridable Function Set (entityType As Type) As DbSet
Parameters
- entityType
- Type
The type of entity for which a set should be returned.
Returns
A set for the given entity type.
- Attributes
Remarks
Note that Entity Framework requires that this method return the same instance each time that it is called for a given context instance and entity type. Also, the generic DbSet<TEntity> returned by the Set(Type) method must wrap the same underlying query and set of entities. These invariants must be maintained if this method is overridden for anything other than creating test doubles for unit testing. See the DbSet class for more details.
Applies to
Set<TEntity>()
Returns a DbSet<TEntity> instance for access to entities of the given type in the context and the underlying store.
public virtual System.Data.Entity.DbSet<TEntity> Set<TEntity> () where TEntity : class;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId="Set")]
public virtual System.Data.Entity.DbSet<TEntity> Set<TEntity> () where TEntity : class;
abstract member Set : unit -> System.Data.Entity.DbSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.Set : unit -> System.Data.Entity.DbSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function Set(Of TEntity As Class) () As DbSet(Of TEntity)
Type Parameters
- TEntity
The type entity for which a set should be returned.
Returns
A set for the given entity type.
- Attributes
Remarks
Note that Entity Framework requires that this method return the same instance each time that it is called for a given context instance and entity type. Also, the non-generic DbSet returned by the Set(Type) method must wrap the same underlying query and set of entities. These invariants must be maintained if this method is overridden for anything other than creating test doubles for unit testing. See the DbSet<TEntity> class for more details.
Applies to
Entity Framework