Data transfer object pattern

后端 未结 3 940
情歌与酒
情歌与酒 2020-12-08 16:34

i\'m sorry i\'m newbie to enterprise application as well as the design pattern. might be this question occcur lack of knowledge about design pattern. i found that its better

3条回答
  •  囚心锁ツ
    2020-12-08 16:44

    An XmlSerializer or JsonSerializer can be used for serializing (loading) XML or Json data from a source (webservice). Or explaining the name DTO: you serialize (transfer) data from a source (webservice) to a (general DTO) object. So DTOs are general purpose objects. Sometimes its clever to make a wide as possible DTO object and fill that completely so you can use from that object whatever you like and copy that to your "own" program objects.

    Example: I developped a program for showing transport navigation data. I serialize the whole xml or json messsage in a DTO object. In this DTO object is more information then I will need in my program and it can be in a different form, so I will use only whats needed. DTO objects makes it more easy to extract data from sources (webservices).

    I dont want to use AutoMapper because of the name "Auto". I want to know what I am doing and think where my data is going to.

提交回复
热议问题