Sunday, April 02, 2006

ADO.NET vs ObjectRelationalMapping

So... why I don't like DataSets? Well, first of all, it is not that I think that DataSets are useless, it is just that I feel that Object Relational Mapping (ORM) is a far better solution, because, when properly built:

  1. You don't have to worry about primary keys of foreign keys (or the proprietary identity mechanism of a particular database)
  2. You don't have to worry about creating the master row first, and the detail rows later (master detail relationships are automatically handled by the ORM)
  3. You don't have to worry about saving all the changes in your data in the proper order(CRUD operations are automatically ordered following master detail relationships)
  4. You can easily add optimistic locking to you code without having to change all your SQL "UPDATE" or "DELETE" code.
  5. Your domain model is more abstracted from the idea that is being read from a database (a really good ORM should be able to read from a different relational source... or perhaps even a hierarchical source (Object Hierarchical Mapper?)... for example... from an XML file.
  6. You automatically get "cache" benefits, transparently, and sometimes you can even plug special caching strategies.

No comments: