与数据表相比,使用POCO有什么优势? [英] What are the advantages of using POCOs over DataTables?
本文介绍了与数据表相比,使用POCO有什么优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在数据访问层中,该层查询数据库并返回可枚举的结果对象,即返回具有属性Name,Age等属性的Dog对象列表,而不是返回具有诸如名称",年龄"等?
In a data access layer, that queries a database and returns an enumerable object of results, what are the advantages of returning say a list of Dog objects with properties Name, Age, etc, instead of a DataTable that has columns like "Name", "Age", etc ?
推荐答案
一些:
- 类型安全
- 不仅对XML进行序列化,而且对JSON和二进制文件进行序列化.
- 可读性
- 更轻巧
- 添加行为的能力
- 能够定义DataAnnotation和验证逻辑
- 使用ORM的能力
这篇关于与数据表相比,使用POCO有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文