Template Documentation
GenericServiceTModel, TEntity Class |
Works as a Generic Service, to use the most commons functions of every service and encapsule them here, to avoid duplicated code.
This class implements IServiceTModel with the common functions and IAutoMapperTModel, TEntity, to map objects between DTO and Entities and viceverse,
The navigation properties will be mapping on a deep of 5 objects by default, if you wanna change that, change de value of MaxDeep on the GenericServiceTModel, TEntity constructor
Inheritance Hierarchy
SystemObject Template.Service.CoreGenericServiceTModel, TEntity
Template.Service.ClassMoviesCategoryService
Template.Service.ClassMoviesService
Template.Service.ClassMoviesCategoryService
Template.Service.ClassMoviesService
Namespace: Template.Service.Core
Assembly: Template.Service (in Template.Service.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public abstract class GenericService<TModel, TEntity> : IService<TModel>, IAutoMapper<TModel, TEntity> where TModel : BaseModel where TEntity : BaseEntity
Type Parameters
- TModel
- The model class of the service
- TEntity
- The entity class of the service
The GenericServiceTModel, TEntity type exposes the following members.
Constructors
Name | Description | |
---|---|---|
GenericServiceTModel, TEntity |
Add an instance of GenericService, also configures the mapping
|
Methods
Name | Description | |
---|---|---|
Add |
Add an entity based on the passed model and insert it on database
| |
AddIEnumetable |
Add an IEnumerable of entities based on the passed models IEnumerable amd insert them on database
| |
Delete |
Add an entity based on the passed model and delete it on database
| |
DeleteBy |
Deletes any match with the given predicate
| |
Edit |
Add an entity based on the passed model and delete it on database
| |
FindBy |
Retuns an IEnumerable of models based on the expresion, retreives entities from the database and convert them to models
| |
Get |
Get an unique model based on the expresion, retreives the entity and convert it to model
| |
GetAll |
Get all the elements of the database, retreives entities from the database and convert them to models
| |
SelectWhereTResult |
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
| |
ToEntity |
Converts a model to an entity
| |
ToEntityEnumerable |
Converts an IEnumerable of Models to an IEnumerable of entities
| |
ToEntityExpression |
Convert an expression of a model to an expression to an Entity, be careful to make an expression of with entities properties
| |
ToEntityFunctionTResult |
Convert a function of a model to a function of a TEntity, be careful to make an function with entities properties
| |
ToModel |
Converts an entity to a model
| |
ToModelEnumerable |
Convert
|
Fields
Name | Description | |
---|---|---|
_mapper |
The IMapper object is used to map objects between TEntity and TModel types
| |
_repository |
The GenericRepository of TEntity to do all the common database functions
|
See Also