DTO in Entity Infrastructure

I plan to implement the NTier project in EF 4. I know that EF itself creates entities based on the tables it displays in the database. My question is, what is the use of DTO (Data Transfer Object), or is it really necessary? It seems like it contributes to redunduncy, since you need to create another DTO object for each entity created by EF. Please guide me. thank..

+3
source share
2 answers

A DTO is a data transfer object used to transfer only the necessary data between physical layers (when the layers are in other processes or on other servers). If you need to set only the person’s name and age, you do not need to pass on your address, work, children, etc. Thus, you will create a simple transport object that will contain only the name and age.

EF will create objects that bind database records to properties. An EF object can also be extended (through partial classes) to a complete domain object using custom computed properties and methods. Domain objects must not be directly exposed at different levels, and this is another case when DTOs are used.

Edit:

, DTO, - . , , , (). DTO, ( ) () , -.

+9

DTO , , . , , , , , .. , DTO.

0

All Articles