C
C#3y ago
JT

Entities and Models, DTOs oh my?

Going through some courses I noticed that some time they use model and entities and other times they are just using models. What is the difference here?
8 Replies
AdmSnyder
AdmSnyder3y ago
entities usually refers to things that are in a DB, models is a Bad Word (TM) that stands for everyThing and, while we're at it: DTO (Data Transfer Object) usually means a specialized Type for a (couple of) specific use cases (that don't require all the info of a specific model or infos from multiples...) basically, i'd recommend you don't worry about the wording here. people tend to be more imprecise than you expect.
JT
JT3y ago
gotcha, so just to be clear here. Entities - reference the data that is in the database. DTOs - specialized types that are used. that are not used to reference db entities ^ would these be correct statements?
AdmSnyder
AdmSnyder3y ago
broadly, i'd say.
Yawnder
Yawnder3y ago
You will also so DAO (Data Access Object) instead of Entities sometimes. Model is quite vague, but if someone speaks of DTO and DAO in the same sentence, they're is a good chance Model refers to what comes in from the API.
JT
JT3y ago
Yeah looking at some documentation and videos it looks like using entities to map to the tables that we are creating in the database while we can use DTO‘s and DAO‘s as contracts that we want to use from an inbound and outbound perspective. would this be a better summary? High-level
MODiX
MODiX3y ago
AdmSnyder#8493
basically, i'd recommend you don't worry about the wording here.
Quoted by
React with ❌ to remove this embed.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Esa
Esa3y ago
DTOs are commonly the things you return to frontend through your controllers. so you and your frontend colleague will usually have an agreement on what to work with, this will be in the form of dtos.
Want results from more Discord servers?
Add your server