Interface IResponseMapper<TResponse, TEntity>
use this interface to implement a domain entity mapper for your endpoints that only has a response dto and no request dto.
HINT: entity mappers are used as singletons for performance reasons. do not maintain state in the mappers.
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public interface IResponseMapper<TResponse, in TEntity> : IResponseMapper, IMapper
Type Parameters
Name | Description |
---|---|
TResponse | the type of response dto |
TEntity | the type of domain entity to map to/from |
Methods
FromEntity(TEntity)
implement this method and place the logic for mapping a domain entity to a response dto
Declaration
TResponse FromEntity(TEntity e)
Parameters
Type | Name | Description |
---|---|---|
TEntity | e | the domain entity to map from |
Returns
Type | Description |
---|---|
TResponse |
FromEntityAsync(TEntity, CancellationToken)
implement this method and place the logic for mapping a domain entity to a response dto
Declaration
Task<TResponse> FromEntityAsync(TEntity e, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
TEntity | e | the domain entity to map from |
CancellationToken | ct | a cancellation token |
Returns
Type | Description |
---|---|
Task<TResponse> |