Data Transfer Object (DTO)
来源:互联网 发布:百度云盘网络证书无效 编辑:程序博客网 时间:2024/05/19 03:44
/*By Jiangong SUN*/
DTO pattern is used to "transfer data" using objects
DTO vs. VO(Value Objects)
Value Object must be immutable, serializable and it’s content must be publicly accessible.
A Value Object can only be changed and persisted by the creation of a new Value Object based on the values of the original Value Object obtained.
A Transfer Object while similar in most respects is mutable. In addition there is a reasonable expectation that the Transfer Object will be persisted if it is returned to the originating layer.
Usage of DTO: It can get attributes from differenct objects and consists as a new object for particular use.
DTO vs. VO(Value Objects)
Value Object must be immutable, serializable and it’s content must be publicly accessible.
A Value Object can only be changed and persisted by the creation of a new Value Object based on the values of the original Value Object obtained.
A Transfer Object while similar in most respects is mutable. In addition there is a reasonable expectation that the Transfer Object will be persisted if it is returned to the originating layer.
Usage of DTO: It can get attributes from differenct objects and consists as a new object for particular use.
In my project i've used it to fill in the asp .net repeater.
Code example:
public class UniverseDTO { public string ImagePath { get; set; } public string Code { get; set; } public string Label { get; set; } public int Order { get; set; } public List<SubUniverseDTO> SubUniverses { get; set; } }
List<UniverseDTO> universes = (from universe in UniversesService.GetUniverses() select new UniverseDTO { Code = universe.code, Label = universe.label, Order = universe.order, ImagePath = newpath, SubUniverses = UniversesService.GetSubUniverses(universe.code) }).OrderBy(x => x.Order).ToList();
Reference :
http://rrees.wordpress.com/2007/05/13/transfer-objects-versus-value-objects/
http://stackoverflow.com/questions/725348/poco-vs-dto
http://martinfowler.com/eaaCatalog/dataTransferObject.html
http://www.adam-bien.com/roller/abien/entry/value_object_vs_data_transfer
http://www.adam-bien.com/roller/abien/entry/how_evil_are_actually_data
http://stackoverflow.com/questions/1612334/difference-between-dto-vo-pojo-javabeans
- Data Transfer Object (DTO)
- CoreData 数据传输对象DTO(data transfer object)
- DTO(data Transfer Object) 的思考
- CoreData 数据传输对象DTO(data transfer object)
- Data Transfer Object
- Data Transfer Object(数据传输对象) [转载]
- Data Transfer Object(数据传输对象)
- Data Transfer Object(数据传输对象)
- Data Transfer Object(数据传输对象)
- 在 .NET 中使用 DataSet 实现 Data Transfer Object
- 在 .NET 中使用 DataSet 实现 Data Transfer Object
- Data Transfer
- 在 .NET 中使用类型化 DataSet 实现 Data Transfer Object
- 在 .NET 中使用类型化 DataSet 实现 Data Transfer Object
- 浅析OpenCL memory(2)——memory object creation flag 以及 data transfer mode
- Part 29 - Using data transfer object as the model in mvc
- Transfer Object between Activity.
- Data Transfer - Data Import develop
- 正则表达式 获取
- vxWorks中USB驱动栈-2
- mysql存储过程(一)
- vs2008 MFC 对话框 敲回车,ESE键,程序自动退出解决办法
- Commons-BeanUtils动态bean在项目中的应用
- Data Transfer Object (DTO)
- AgilePoint模型驱动BPM(业务流程管理)介绍
- spring XmlWebApplicationContext详解
- ACM ICPC 3252 Round Numbers
- 【9月13日】宁大队内选拔赛
- MySQL
- Http小结
- 上海-苏州 100公里徒步旅行心情分享(二)
- Max Levchin与Peter Thiel谈创新:“一半是海水,一半是火焰”