© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
25 replies
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
}
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
}
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;
}
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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

DTOs inside of DTOs
C#CC# / help
4y ago
REST? DTOs
C#CC# / help
4y ago
Where to map DTOs & Entities
C#CC# / help
4y ago
How to structure this DTO?
C#CC# / help
4y ago