Class EndpointWithMapping<TRequest, TResponse, TEntity>
use this base class for defining endpoints that use both request and response dtos as well as require mapping to and from a domain entity.
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public abstract class EndpointWithMapping<TRequest, TResponse, TEntity> : Endpoint<TRequest, TResponse>, IEndpoint, IEventBus, IServiceResolverBase where TRequest : notnull
Type Parameters
Name | Description |
---|---|
TRequest | the type of the request dto |
TResponse | the type of the response dto |
TEntity | the type of domain entity that will be mapped to/from |
Methods
MapFromEntity(TEntity)
override this method and place the logic for mapping a domain entity to a response dto
Declaration
public virtual TResponse MapFromEntity(TEntity e)
Parameters
Type | Name | Description |
---|---|---|
TEntity | e | the domain entity to map from |
Returns
Type | Description |
---|---|
TResponse |
MapFromEntityAsync(TEntity, CancellationToken)
override this method and place the logic for mapping a domain entity to a response dto
Declaration
public virtual Task<TResponse> MapFromEntityAsync(TEntity e, CancellationToken ct = default)
Parameters
Type | Name | Description |
---|---|---|
TEntity | e | the domain entity to map from |
CancellationToken | ct | a cancellation token |
Returns
Type | Description |
---|---|
Task<TResponse> |
MapToEntity(TRequest)
override this method and place the logic for mapping the request dto to the desired domain entity
Declaration
public virtual TEntity MapToEntity(TRequest r)
Parameters
Type | Name | Description |
---|---|---|
TRequest | r | the request dto |
Returns
Type | Description |
---|---|
TEntity |
MapToEntityAsync(TRequest, CancellationToken)
override this method and place the logic for mapping the request dto to the desired domain entity
Declaration
public virtual Task<TEntity> MapToEntityAsync(TRequest r, CancellationToken ct = default)
Parameters
Type | Name | Description |
---|---|---|
TRequest | r | the request dto to map from |
CancellationToken | ct | a cancellation token |
Returns
Type | Description |
---|---|
Task<TEntity> |