Data Transfer Objects Best Practices & Conventions

  • Do define DTOs in the application contracts package.
  • Do inherit from the pre-built base DTO classes where possible and necessary (like EntityDto<TKey>, CreationAuditedEntityDto<TKey>, AuditedEntityDto<TKey>, FullAuditedEntityDto<TKey> and so on).
  • Do define DTO members with public getter and setter.
  • Do use data annotations for validation on the properties of DTOs those are inputs of the service.
  • Do not add any logic into DTOs except implementing IValidatableObject when necessary.
  • Do mark all DTOs as [Serializable] since they are already serializable and developers may want to binary serialize them.

Contributors


Last updated: December 10, 2018 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

In this document
Community Talks

Building Modular Monolith Applications Using .NET and ABP Framework

17 Oct, 17:00
Online
Watch the Event
Mastering ABP Framework Book
Mastering ABP Framework

This book will help you gain a complete understanding of the framework and modern web application development techniques.

Learn More