Designing DTOs
A DTO is a simple object used to transfer data between the presentation and the application layers. Let’s start by seeing the basic principles of designing DTO classes.
Designing DTO classes
There are some fundamental principles to follow while defining DTO classes, as outlined here:
- DTOs should not contain any business logic; they are just for data transfer.
- DTO objects should be serializable because most of the time, they are transferred over the wire. Typically, they have a parameterless constructor, and all of their properties have public getters and setters.
- DTO classes should not inherit from the entities or use entity types as their properties.
The following DTO class is used to store the data while adding a new session to an existing track of an event:
public class AddSessionDto { [Required] [StringLength(SessionConsts.MaxTitleLength, ...