Should the repository layer return data-transfer-objects (DTO)?

Short answer: No.

Long answer: repository is responsible for turning persisted data back to entities (models) and vice versa.

Model is a business Model representing a business entity. DTO on the other hand – while looks like Model – is concerned with transfer of the object between various environment and in essence is a transient object. Usually mappers are responsible for turning model into DTO.

Leave a Comment