Hilton Giesenow's Jumbled Mind

Wednesday, July 07, 2004

Some gripes about Typed Datasets and sqlDataAdapters

I am currently working on quite an interesting project. We have put out business and data layers a bit closer than usual, and are making use of typed datasets passed via Web to the presentation layer. I've touched on aspects of this type of Service Architecture approach before, but not quite in this way. We have encountered particularly irritating points so far. One is that the ADO.NET dataadapters are not able to deal with parent-child updating properly, and the other relates to annotating typed datasets.

The XML schemas for an ADO.NET typed dataset allows you to specify relationships between its tables. However, when you try and Update the changes using a DataAdapter it does not handle the changes correctly. The Update method iterates through the items sequentially, as one might expect. This causes problems though depending on the type of transaction. If the update method attacks the parent table first, and it processes a Delete, the children become orphaned. On the other hand, if you update the children first on an Insert, they become marked as Unchanged, and will not be updated when the parent is Inserted into the database and receives its proper real primary key. What we had to do was similar to the solution found in KB 310350 - How to update parent-child data with an Identity column from a Windows Forms application by using a Web Service in Visual Basic .NET. However, even this did not quite work. If anyone is interested in the solution, let me know and I'll provide more info.

The second problem related, as I mentioned, to annotating typed datasets (e.g. see Using Annotations with a Typed and also Using Annotations with a Typed DataSet). This concept allows the auto-generated objects to have proper names. For example, we have a convention of prefixing our lookup tables with "tlkp". Using these annotations, we can create a Audit type, and the table is called Audits, as opposed to the auto-"tlkpAudit" and "tlkpAuditTable". Much nicer :-). In addition, annotations let you specify defaults, etc. Now, using a typed dataset is fine with a Web Service. Adding the reference in Visual Studio.NET 2003 automatically pulls the schema across to the client application. HOWEVER (!!!) it does NOT pull the annotations! Nobody has yet been able to explain this one to me, and it is quite frustrating! Any comments would be appreciated!

Anyways, that's it for today. Back to the grind...

0 Comments:

Post a Comment

<< Home