GenericRepository(TEntity) Class

Template MVC

GenericRepositoryTEntity Class

Generic repository with all the basic functions of ebery repository, all repositories will inherit of this class
Inheritance Hierarchy
SystemObject  Template.Repository.CoreGenericRepositoryTEntity
    Template.Repository.ClassMoviesCategoryRepository
    Template.Repository.ClassMoviesRepository

Namespace:  Template.Repository.Core
Assembly:  Template.Repository (in Template.Repository.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class GenericRepository<TEntity> : IGenericRepository<TEntity>
where TEntity : BaseEntity

Type Parameters

TEntity
The entity class than represents a database table

The GenericRepositoryTEntity type exposes the following members.

Constructors
  NameDescription
Public methodGenericRepositoryTEntity
The GenericRepository constructor
Top
Methods
  NameDescription
Public methodAdd
Add a new entity to the context, it will be added to the database on Save
Public methodAddIEnumerable
Add a IEnumerable of new entities to the context, they will be added to the database on Save
Public methodDelete
Marks the given entity as deleted, the entity will be deleted on Save
Public methodDeleteBy
Marks the entities that match with the given predicate as deleted, they will be deleted of the database on Save
Public methodEdit
Marks the passed entity as Modified, the changes will persist on Save
Public methodFindBy
Filters the results by the passed predicate
Public methodGet
Gets an unique TEntity from the database
Public methodGetAll
Get all the results of the IEntity
Public methodSave
Save all the changes made to the context
Public methodSelectWhereTResult
This function allows to select the specific properties and filter by where clause on database, not on memory, in that way it improves the performace
Top
Fields
  NameDescription
Protected field_DBEntities
The DbContext of entity framework
Protected field_Entity
The DbSet that represents the database table to do all the queries
Top
See Also