DTOs and mapping (e.g. AutoMapper)?
- DTOs decouple internal models from API contracts.
- Use AutoMapper for mapping:
CreateMap<Product, ProductDto>();
var dto = _mapper.Map<ProductDto>(product);
CreateMap<Product, ProductDto>();
var dto = _mapper.Map<ProductDto>(product);