tags:

views:

250

answers:

2

DataSet is not ORM but it is possible to build an ORM with Dataset http://www.15seconds.com/issue/080103.htm

This kind of article is very rare as people seem to oppose Datasets and ORMs so any other example ?

+1  A: 

An ORM is a fundamentally different thing than DataSets.

DataSets are very much a 1:1 copy of your relational database tables in memory; a DataSet contains multiple DataTables, each made up of columns and rows. It's more or less a "relational database in memory" - no mapping, no translation - just a 1:1 copy.

All good and fine if you're comfortable with working in this column/row style (which works for many cases).

An ORM is a totally different beast - as the name says, it's an Object-Relational Mapper, e.g. it maps those relational columns and rows into domain objects and collections thereof in your domain model. It does a mapping between columns and rows into collection of objects with properties.

You're no longer dealing with a customers table, but instead you're dealing with customer objects, lists of customers and so forth. You're programming against a "normal" business object, and the ORM will take care of mapping that to tables and columns and rows for you when you save it.

Since the DataSet is more or less a 1:1 copy of your database, you could in theory put an ORM on top of that to get objects from it - but what's the point? Why even go the route of having a DataSet in the first place, when you want to use an ORM in end anyway?? I don't see any benefit in that approach...

Explain to me (and the other Stackoverflowers) why you want to use DataSets and an ORM on top of that? What's your goal, what's your idea / approach??

So it's really about choosing between DataSets or ORMs - either will work, either caters to a different programming and architecture style. Pick yours and be happy with it.

Marc

marc_s
Datasets are simple bricks which you can use to build other stuffs like ORM in this case. That's what 15 seconds article did, so did you read the article or are you saying the author is nuts to even conceive the idea ?
programmernovice
just a 1:1 copy. That doesn't seem true to me, as the article says you are not obliged to have exact matching with the database since it is an independant layer.
programmernovice
Let's suppose it's even true, as far as I know ActiveRecord is just an 1:1 mapping also and that doesn't prevent to be considered a good ORM scheme so what's the problem ?
programmernovice
"You're programming against a "normal" business object, and the ORM will take care of mapping that to tables and columns and rows for you when you save it."And what prevents to have a Business Object sitting on Top on Datasets ?
programmernovice
There's nothing inherently wrong with building an ORM on top of DataSets - I just don't see any benefit in doing so. Why load your data from the DB into a DataSet first, before converting it to a business object? If you want to use an ORM - why not just let the ORM access the database? I just don't see any benefit and any gain in adding this extra layer of a "in-memory database" called DataSet....
marc_s
@marc_s well I just ask a question about EF http://stackoverflow.com/questions/1449044/is-entity-framework-tied-to-sql-server/1449048#1449048 There's no real provider for Oracle and none for MS Access, the two I would like to use bad luck :)
programmernovice
ORM seems like EJB for me.
programmernovice
A: 

I agree with marc_s's comments.

The article which you refer to appears to be a bit dated. It is trying to use a Dataset as an ORM tool, at a time when the availability of ORM tools was more limited than it is now.

I would recommend that you look at Entity Framework (an ORM), it supports the active record pattern, as well as having UI tools similar to datasets. If all you do is auto-generate your entities based on your database, you may not notice a big difference from using datasets.

http://msdn.microsoft.com/en-us/library/aa697427%28VS.80%29.aspx

Shiraz Bhaiji
The article says:"There are many ORM tools available on the market, some expensive and some relatively inexpensive, and most do a good job of generating data entities and some even generate the data structure for business objects. If you have the budget and don't mind working with the pre-defined architecture, then pick one and go with it. Another option is to use the power of datasets as an ORM tool."So for sure it wasn't a bit dated. It isn't trying at all, it does create an ORM Tool.I want to use dataset because I can evolve from a simple stuff to a more complex stuff.
programmernovice
Also I fear that Entity Framework is too tight to SQL Server and overcomplicated for my need.
programmernovice
Entity Framework is not tied to SQL Server and it's not very feature rich compared to something like NHibernate. You are welcome to build your own ORM, it will take forever, cost a ton of time/money, and be feature poor.
Michael Maddox