Search code examples
datasetstrong-typing

Best "current" MS data access technology for loose coupled constantly changing code?


I do a lot of untyped dataset work in my projects and have done so for a while but when working with in-place editing of datagridview I found it's a lot easier for validation and stuff if you use a Typed Dataset.

This poses an issue though because I don't like using those dataset designers to create strongly typed datatables/datasets. It makes it harder to make simple changes down the road when the dataset is typed than it does with untyped. Typed dataset changes require a copy of VS to be installed whereas untyped doesn't. I can change a sql view on the db server and the apps will show the new column in my grid. They may not be able to use the new column but most of my stuff is info display so that's ok.

I looked at Entity Framework, but it too looks like a few wizards must run to build your data model. I'm not against a data model but it would be great if it would generate at runtime so that new changes to the db don't require software recompiling.

Is there a happy medium? Or am I stuck creating untyped datatables at startup for a while longer?


Solution

  • It's all a matter of taste, of course, but I find that Datasets are the root of all evil.
    well, maybe not all evil, but they represent a data structure that has no behavior associated with it => they are not objects (as defined in OOP) => using them promotes non-OOP style programming (not to mention procedural programming).

    some other points:

    1. gridviews and any other control fully support binding to a list of objects (and not just datasets).
    2. I think that, if you have to make changes to your data model, having a copy of VS installed is not too much to ask.
    3. along the same lines- it's also not an exaggerated requirement to have to recompile your code when you make changes to your data model.
    4. if, when you change a table in your db, that forces a change on your UI, I would say it's not "loosely coupled" by any stretch of the imagination.

    I believe that the only justification for using datasets is to pull data out of your db and then transfer it into your objects.
    but now, as you know, if that isn't necessary- you have ORMs that do that job for you (EF is one, nHibernate is another, better, option).

    so, in conclusion- I strongly recommend you reconsider your use of DataSets, as they go against the very basics of Object-Oriented.

    p.s.
    sorry if this came across as a little emotional- I was talking from bitter personal experience.
    I was pulling my hair out for 2 years because the app I was working on had used DataSets all over, and that meant that we had to duplicate the behavior for that data all over as well. uughh....