C#C
C#4y ago
D.Mentia

❔ How to structure DTOs

If you're making a DTO, do you make it like this
public class UpdateStudentDTO
{
  public int Id;
  public string? Name;
  public string? Address; // etc
}

Or like this
public class StudentDTO{
  OperationTypes Type; // OperationTypes.Update, .Create, .Delete
  public int? Id;
  public string? Name; // etc
}

Or like this
public class UpdateStudentDTO{
  public int Id;
  public Student FieldsToUpdate;
}



Basically, should there be one DTO that is used for all OperationTypes, or one endpoint and DTO per type (Update/Delete/Etc)?
And the last one is quite bad, I'm sure, but if the Student is complex and long, would it ever be acceptable?
Was this page helpful?