Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of using POCOs over DataTables?

Tags:

c#

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 ?

like image 980
Brian Smith Avatar asked May 06 '11 16:05

Brian Smith


1 Answers

A few:

  • Type safety
  • Serialisation not just to XML but JSON, binary ...
  • Readability
  • More light-weight
  • Ability to add behaviours
  • Ability to define DataAnnotation and validation logic
  • Ability to use ORMs
like image 120
Aliostad Avatar answered Oct 19 '22 01:10

Aliostad