Does anyone use typed DataSets in .NET?

I once tried using typed DateSets in a relatively small production application. Initially, it looked pretty good, but it turned out to be different. This was very good for some basic tasks, but as soon as something more advanced was required, it limited him and he failed. Fortunately, the project has been canceled, and now I'm trying to stick with a proper ORM like NHibernate.

But I still wonder - they were created for a reason. Perhaps I just did not understand how to use them correctly? Does anyone successfully use them in production systems?

Added:

Could you also explain how you use them?

I tried to use them as my DAL - these are Windows Forms applications, and it will retrieve data from tables in the DataSet and then manipulate the data before invoking the hierarchical update of the TableManager (do not remember the exact name). The DataSet had one table for each physical database table. The problems started when I had to do something like a master / details relationship, where I had to insert several records at once (one main record and several data records) into several tables, and also save foreign keys correctly.

Added 2:

Oh, and if you use them, then where do you put your business logic? (Validations, calculations, etc.)

+4
source share
7 answers

We use typed datasets all the time, in fact we use them as best practices. The reason we do this is to catch errors at compile time rather than use row searching for column names that can lead to runtime errors.

I think, as always, it depends on the scenario and whether you have any advantage for using them or not.

Normal line:

 oRow["row_pk"] 

In a typed dataset, it now becomes:

 oRow.row_pk 

Our data sets usually correspond to the database, we use DataAdapters to update changes to the database using stored procedures. The output parameters update the dataset using the keys generated from the database.

Obviously, you need to run adapter updates in the correct order for all keys to generate in the correct order. You should also be careful when deleting parent / child rows and make sure that these deletions occur in the correct order to prevent database exceptions.

Back when .NET was still 1.1 I read a book about ADO.NET from David Seppa that opened my eyes to what could actually be achieved and simplify my DAL (using typed datasets). There are many methods that can really help improve your code, I would highly recommend it.

+4
source

It was useful for me to create XML documents for submission to a web service. The client defined the expected data as typed DataSets and made it very easy to create a DataTable in memory and get an XML view.

Now, for real access to the database ... I use my own DAL, I agree with you - DataSets are incredibly limited.

+3
source

I use them when: 1) Writing "1-offs", which are deleted after the completion of the project we are working on. 2) Using XML files to exchange data with other providers. 3) Prototyping and testing,

I had problems with a typed dataset when: 1) Complex queries are required to filter and save data. (at least for me) 2) Not knowing what the Visual Studio designer writes on my behalf so that I can extend the derived class created for typed datasets.

I've never had a problem with given datasets, and users seem to be happy with the applications created with them. Honestly, I did not compare different methods that could replace typed datasets. Finally, I was saved more than once by checking the type of development time that would be overlooked by a novice programmer, like me, using typed datasets.

Yours faithfully,

debug

+3
source

I use them. Perhaps only because I have not tried NHibernate, but I can’t use LINQ, because I am limited to Windows 2000, which does not run .NET 3. At first they seemed perfect, but I found strange enough quirks about them to make me disconnect .

+2
source

This is exactly what is required if you believe in software for writing software and static typing - software software errors - due to complexity (for sure), development overhead (maybe) and efficiency (maybe, but debatable) is the basic premise of languages ​​like C # and java.

This, however, is not a battle that has been fully won.

EDIT (requested explication):

Complexity.

Using C # or java, you get a lot of code for configuration, type declaration, casting, type checking and validation. You write some of them yourself, some IDEs write for you. But the developer is responsible for all this. The main advantages for the IDE / compiler are an indication of possible software errors and autocomplete. I can safely say, without accepting either side, that there is an industry discussion about whether volume is in the lines of code. This is at least a clear violation of YAGNI. In VS, I usually come across whole code files written by the IDE that have errors that I ultimately need to find out. I do not like to compute code that I did not write.

Development overhead.

The same as above. And Java is well known for all the XML configuration files that you need to write and maintain so that the application matches each other. RoR's biggest attraction is “convention configuration,” just to avoid it.

Efficiency.

The assertion that interpreted or JIT-compiled languages ​​are terribly inefficient compared to compiled languages ​​has long been taken for granted. For many reasons than I have time for this, this assumption is being called into question; for example, some newer, faster javascript engines.

The obvious things to search on this site and google for are late binding, dynamic typing, and JIT compiler.

+2
source

I use them, but not in the usual sense. This is similar to ocdecio's answer, although in my case it is like a view model (without table adapters) in asp.net

The client services layer uses them (as part of the contract) for any method that receives or returns data. Basic business services use the more traditional poco approach, and client services simply perform a little mapping to create a strongly typed dataset for a given ui.

Tool support greatly simplifies the work of new developers (who can follow asp.net/learn videos to get speed) to use the required services. User interface developers can also quickly “develop” a new set of data that they would like to receive, and from there they will have an appropriate service team.

+2
source

I still use them more than I would like ... They are definitely better than untyped datasets, but you have to be careful with fields like NULL. If you have an Int field that can contain a null value, you cannot try to access the field when it is null or it will throw an exception. You must first call IsMyIntFieldNull () to check if it is / is invalid. This means that your code refers to one of these fields, you need to do this check first ... which easily adds up to a huge amount of extra code. It would be better if the typed datasets support fields with a null value for these columns, but, unfortunately, they do not.

+1
source

All Articles