Skip to main content
A newer version of this page is available. .

IRepository<TEntity, TPrimaryKey> Methods

The IRepository interface represents the read and write implementation of the Repository pattern such that it can be used to query entities of a given type.
Name Description
Add(TEntity) Marks the given entity as Added such that it will be commited to the store when IUnitOfWork.SaveChanges is called.
Create(Boolean) Creates a new instance of the entity type.
Find(TPrimaryKey) Finds an entity with the given primary key value.
GetEnumerator() Returns an enumerator that iterates through the collection. Inherited from IEnumerable<T>.
GetPrimaryKey(TEntity) Returns the primary key value for the entity.
GetState(TEntity) Returns the state of the given entity.
HasPrimaryKey(TEntity) Determines whether the given entity has the primary key assigned (the primary key is not null).
Include<TProperty>(Expression<Func<T, TProperty>>) Specifies the related objects to include in the query results. Inherited from IRepositoryQuery<T>.
Reload(TEntity) Reloads the entity from the store overwriting any property values with values from the store and returns a reloaded entity.
Remove(TEntity) Marks the given entity as EntityState.Deleted such that it will be deleted from the store when IUnitOfWork.SaveChanges is called.
SetPrimaryKey(TEntity, TPrimaryKey) Assigns the given primary key value to a given entity.
Update(TEntity) Changes the state of the specified entity to EntityState.Modified if changes are not automatically tracked by the implementation.
Where(Expression<Func<T, Boolean>>) Filters a sequence of entities based on the given predicate. Inherited from IRepositoryQuery<T>.
See Also