Export (0) Print
Expand All

IDbSet<TEntity> Interface

Entity Framework 5.0

Represents the collection of all entities in the context, or that can be queried from the database, of a given type. DbSet is a concrete implementation of IDbSet<TEntity>.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

public interface IDbSet<TEntity> : IQueryable<TEntity>, 
	IEnumerable<TEntity>, IQueryable, IEnumerable 
where TEntity : class

Type Parameters

TEntity

The type that defines the set.

The IDbSet<TEntity> type exposes the following members.

  NameDescription
Public propertyElementType (Inherited from IQueryable.)
Public propertyExpression (Inherited from IQueryable.)
Public propertyLocalReturns ObservableCollection<T> that represents entities of the set that are currently being tracked by the context and have not been marked as Deleted. Accessing the Local property never causes a query to be sent to the database. This property is usually used after a query has already been executed.
Public propertyProvider (Inherited from IQueryable.)
Top

  NameDescription
Public methodAddAdds the given entity to the context the Added state. When the changes are being saved, the entities in the Added states are inserted into the database. After the changes are saved, the object state changes to Unchanged.
Public methodAttachAttaches the given entity to the context in the Unchanged
Public methodCreate()Creates a new instance of an entity for the type of this set. This instance is not added or attached to the set. The instance returned will be a proxy if the underlying context is configured to create proxies and the entity type meets the requirements for creating a proxy.
Public methodCreate<TDerivedEntity>()Creates a new instance of an entity for the type of this set or for a type derived from the type of this set. This instance is not added or attached to the set. The instance returned will be a proxy if the underlying context is configured to create proxies and the entity type meets the requirements for creating a proxy.
Public methodFindUses the primary key value to attempt to find an entity tracked by the context. If the entity is not in the context then a query will be executed and evaluated against the data in the data source, and null is returned if the entity is not found in the context or in the data source. Note that the Find also returns entities that have been added to the context but have not yet been saved to the database.
Public methodGetEnumerator() (Inherited from IEnumerable<TEntity>.)
Public methodGetEnumerator() (Inherited from IEnumerable.)
Public methodRemoveMarks the given entity as Deleted. When the changes are saved, the entity is deleted from the database. The entity must exist in the context in some other state before this method is called.
Top

  NameDescription
Public Extension MethodAddOrUpdate<TEntity>(TEntity[])Overloaded. Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can be useful when seeding data using Migrations. (Defined by IDbSetExtensions.)
Public Extension MethodAddOrUpdate<TEntity>(Expression<Func<TEntity, Object>>, TEntity[])Overloaded. Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can be useful when seeding data using Migrations. (Defined by IDbSetExtensions.)
Public Extension MethodAsNoTracking()Overloaded. Returns a new query where the entities returned will not be cached in the DbContext or ObjectContext. (Defined by DbExtensions.)
Public Extension MethodAsNoTracking<TEntity>()Overloaded. Returns a new query where the entities returned will not be cached in the DbContext or ObjectContext. (Defined by DbExtensions.)
Public Extension MethodInclude(String)Overloaded. Specifies the related objects to include in the query results. (Defined by DbExtensions.)
Public Extension MethodInclude<TEntity>(String)Overloaded. Specifies the related objects to include in the query results. (Defined by DbExtensions.)
Public Extension MethodInclude<TEntity, TProperty>(Expression<Func<TEntity, TProperty>>)Overloaded. Specifies the related objects to include in the query results. (Defined by DbExtensions.)
Public Extension MethodLoadAn extension method on IQueryable that enumerates the results of the query. This is equivalent to calling ToList without actually creating the list. (Defined by DbExtensions.)
Top
Show:
© 2014 Microsoft