#1 2017-11-27 15:26:00

Hmdsadeghian
Member
Registered: 2017-11-25
Posts: 31

Difference between DTO and entity

Hi all,

What is difference between DTO vs entities that inherited from TSQLRecord? and when be used?

Thanks in advance

Offline

#2 2017-11-27 18:27:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,269
Website

Re: Difference between DTO and entity

DTO should not inherit from TSQLRecord, since they should be uncoupled for all persistence details.

Idea is to define custom DTO types as records or as TSynAutoCreateFields classes.

Offline

#3 2017-11-28 09:52:38

Hmdsadeghian
Member
Registered: 2017-11-25
Posts: 31

Re: Difference between DTO and entity

Thank you very much AB

Do you have any sample about using DTO and entities with together that how can I mapping between DTO and domain entities?
Your sample about DTO only using DTO .

Thanks again

Offline

#4 2017-11-29 10:47:44

wloochacz
Member
Registered: 2015-01-03
Posts: 45

Re: Difference between DTO and entity

Hmdsadeghian,

Did you read it?
https://github.com/synopse/mORMot/tree/ … ical%20DDD

In example 04 you have shown how to combine DTO with SQLRecord...
https://github.com/synopse/mORMot/blob/ … sitory.pas

Offline

#5 2017-11-29 12:06:08

Hmdsadeghian
Member
Registered: 2017-11-25
Posts: 31

Re: Difference between DTO and entity

Thanks a lot

Offline

#6 2017-11-29 16:47:16

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Difference between DTO and entity

I just use TSQLRecord-descendants, it feels handy, simple and no over-abstraction, and so far I don't see any drawbacks.

I know people must use DDD/DTO for a reason, but so far I feel it's a little over-abstraction for my own purpose, I might be wrong wink


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB