Class Mapper<TRequest, TResponse, TEntity>
use this base class to define domain entity mappers for your endpoints.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Inheritance
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public abstract class Mapper<TRequest, TResponse, TEntity> : IMapper, IServiceResolverBase
Type Parameters
Name | Description |
---|---|
TRequest | the type of request dto |
TResponse | the type of response dto |
TEntity | the type of domain entity to map to/from |
Methods
CreateScope()
use this base class to define domain entity mappers for your endpoints.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Declaration
public IServiceScope CreateScope()
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceScope |
FromEntity(TEntity)
override this method and place the logic for mapping a domain entity to a response dto
Declaration
public virtual TResponse FromEntity(TEntity e)
Parameters
Type | Name | Description |
---|---|---|
TEntity | e | the domain entity to map from |
Returns
Type | Description |
---|---|
TResponse |
FromEntityAsync(TEntity, CancellationToken)
override this method and place the logic for mapping a domain entity to a response dto
Declaration
public virtual Task<TResponse> FromEntityAsync(TEntity e, CancellationToken ct = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TEntity | e | the domain entity to map from |
System.Threading.CancellationToken | ct | a cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResponse> |
Resolve(Type)
use this base class to define domain entity mappers for your endpoints.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Declaration
public object Resolve(Type typeOfService)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeOfService |
Returns
Type | Description |
---|---|
System.Object |
Resolve<TService>()
use this base class to define domain entity mappers for your endpoints.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Declaration
public TService Resolve<TService>()
where TService : class
Returns
Type | Description |
---|---|
TService |
Type Parameters
Name | Description |
---|---|
TService |
ToEntity(TRequest)
override this method and place the logic for mapping the request dto to the desired domain entity
Declaration
public virtual TEntity ToEntity(TRequest r)
Parameters
Type | Name | Description |
---|---|---|
TRequest | r | the request dto |
Returns
Type | Description |
---|---|
TEntity |
ToEntityAsync(TRequest, CancellationToken)
override this method and place the logic for mapping the request dto to the desired domain entity
Declaration
public virtual Task<TEntity> ToEntityAsync(TRequest r, CancellationToken ct = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TRequest | r | the request dto to map from |
System.Threading.CancellationToken | ct | a cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TEntity> |
TryResolve(Type)
use this base class to define domain entity mappers for your endpoints.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Declaration
public object TryResolve(Type typeOfService)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeOfService |
Returns
Type | Description |
---|---|
System.Object |
TryResolve<TService>()
use this base class to define domain entity mappers for your endpoints.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Declaration
public TService TryResolve<TService>()
where TService : class
Returns
Type | Description |
---|---|
TService |
Type Parameters
Name | Description |
---|---|
TService |
UpdateEntity(TRequest, TEntity)
override this method and place the logic for mapping the updated request dto to the desired domain entity
Declaration
public virtual TEntity UpdateEntity(TRequest r, TEntity e)
Parameters
Type | Name | Description |
---|---|---|
TRequest | r | the request dto to update from |
TEntity | e | the domain entity to update |
Returns
Type | Description |
---|---|
TEntity |