Oops! Typed Datasets ARE scalable!

Note: This is part 3 of 3 articles on this subject:

I was wrong about typed datasets. I see the light now, but i was wrong before.

The conclusion I came to was that Typed Datasets can be used in an enterprise application. The reason I thought this was a problem had to do with one missing link. An important link.

 The Problem I had with datasets performing as business objects was that I thought that once you create a typed dataset, every layer that wants to use this dataset must have a direct reference to the assembly in which the DataSet resided in. I didn't  know of another way one would go about doing this.

Addy Santo wrote in a comment to the last article ("TD's are not always the answer"):

"I'm currently working on a large enterprise app which is heavily based on typed-datasets. I used to be from the "typed-datasets-are-for-newbies-only" camp but I must admit that *when used correctly* they are an incredibly powerful tool. Several key things to keep in mind when architecturing around typed datasets:

1. Equating TDSes to the data layer is like limiting XSLT to the presentation layer - that is only one use among the many existing possibilities.

2. Since TDSes are based on XSD schemas, you can load any arbitrary XML block (which matches your schema) and programmatically work against it with a HIGHLY-PERFORMANT object model. XPath queries over the same XML aren't even in the same ballpark.

 3. Since TDSes are typed, you get compile time validation, as compared to XML/XPath which is a pain to debug.

4. TDSes come with built-in serialization capabilities and funky webservice related optimizations. I don't have the bandwidth to describe my architecture in detail, but I am using datasets in several different capacities in my app and in every case they improved performance, reduced the amount of hand-written code and simplified the data structures. "

This comment contradicted my immediate sense of N-Tier design. How could one both use TD's in the scenarios Addy described and not break the abstraction layers?

 I Started thinking on one of the things I'm working on right now. It involves loading a dataset dynamically from an XML file. In some debugging scnarios I made the Dataset (which is untyped) generate its XSD file for me, so that i could load it up in VS.NET and see the structure of the data as it is represented in the dataset.

I started thinking, "how can two different clients share the same typed dataset from a data source, of which they know nothing about, let alone have references to its DLL's?"

I guessed the XSD had something to do with this, since it is the way to pass around the schema of the data. I continued the out loud discussion with myself (with everyone in the room watching):

"OK. Suppose the Data source exposed the XSD schema to its clients. How would that help them? " The answer popped in right away: "A client should be able to generate a TD using the XSD schema as a blueprint.".

Typing out one small line in Google brought on This Link . voila.

To the rescue comes XSD.Exe which automatically generates Class code from an Xsd schema. The missing link was found. Now, all a client needs to do to be able to use typed datasets on data is to generate them from an XSD file the server exposes.

Simple and easy. Now you get all the power of TD's but without the handicap of references. TD's are not limited to Data Layers.

That's definitely good news (And I learned a lot!)

Published Monday, May 05, 2003 7:20 PM by RoyOsherove
Filed under:

Comments

Monday, May 05, 2003 12:20 PM by TrackBack

# ISerializable

ISerializable
Monday, May 05, 2003 12:20 PM by TrackBack

# ISerializable

ISerializable
Monday, May 05, 2003 12:20 PM by TrackBack

# ISerializable

ISerializable
Wednesday, May 14, 2003 6:27 PM by Christian Weyer

# re: Oops! Typed Datasets ARE scalable!

OK, after having gone to nearly all of the articles & posts related to this very interesting topic: I find TDS an extreme powerful and also scalable programming model, absolutely. Therefore, the comments I have here are mostly from a comment I posted on Clemens' weblog ...
If I now want to share the data inside an TDS across boundaries - e.g. through a Web Services interface - I have several options. 1) Just pass back an instance of the TDS schema-based class back from your WebMethod. That is easy but always emits the Schema embedded. Is this bad? Well, there might be some cases ... 2) Just serialize the TDS to stream without any schema, just the data (serialized InfoSet) and return this one. Is this bad? Well, in some cases ... Additionally, the thing with interoperability is homehow a weak argument. The WSDL of a TDS-enabled Web Service always exposes the schema - so it is just not my fault that Axis or any other SOAP toolkit currently does not have a magic wizard DataSet class, but they are definitely able to understand me and work with me and my data.
Actually, when exposing TDSes through a Web Services interface I do not have to care about supplying the client with the TDS class - they get generated from the WSDL.

To come to a conclusion, I just want to say that there might not be *the* way for using and passing TDS. I like them because they ease the programming with databases and smoothly fit into the Web Services picture, IMHO.

Cheers,
Christian
Sunday, November 16, 2003 11:14 AM by Oskar Austegard

# re: Oops! Typed Datasets ARE scalable!

How exactly does one go about using a TDS effectively in a different project, given that the DataColumns are marked as internal?

Say I have the folowing solution with three projects:
MySol
* DAL
* Entities
* Web

If I create all my TDS in the Entities project, how will I be able to reference the DataColumn properties from within the DAL or Web project? This appears to me to be a major drawback of using TDS - at least as VS.NET generates them.

Thanks,

Oskar
Monday, November 17, 2003 8:27 AM by Roy Osherove

# re: Oops! Typed Datasets ARE scalable!

Hi Oskar. These are declared internal because what you really want to use from extrenal components aree the "public" properties that each row exposes whihc are essentially the columns that you are looking for. So why hide the columns themselves? I asked Mike Gunderloy and he came up with a reasonable explanation: To keep that columns access logic in one place. SOunds reasonable to me..
Monday, November 17, 2003 1:44 PM by Oskar Austegard

# re: Oops! Typed Datasets ARE scalable!

The probem I have with that is that if you want to bind a grid, say in the presentation layer to a TDS from a different project, you have no access to the column names, like you do from inside the assembly, which means you have to resort to using strings (which get checked at runtime) rather than the lengthy but compiler safe myDS.myDT.myCol.columnname syntax. I have run into some other issues related to this as well, but don't remember them at the moment....
Wednesday, January 14, 2004 9:04 PM by TrackBack

# re: Typed Datasets Are Not Always The Answer

Tuesday, February 03, 2004 5:57 PM by Some DUde

# re: Oops! Typed Datasets ARE scalable!

So I generate a Typed dataset....in the IDE
Fine
Now How do I subclass it for my custom stuff... Lets aviod the arguments over if this is addressing buisness rule or not.. How To Please..
Override every thing ??


Nevermind the adoguy had the answer already..
class DerivedDataSet : TypedDataSet
{
public void MyFunction()
{
}
}

http://www.adoguy.com
Tuesday, March 30, 2004 1:15 PM by TrackBack

# Oops! Typed Datasets ARE scalable!

Friday, April 02, 2004 9:43 AM by TrackBack

# [NotSo]DailyBytes.Add(

Friday, April 02, 2004 9:44 AM by TrackBack

# [NotSo]DailyBytes.Add(

Monday, April 05, 2004 9:39 AM by Bnaya Eshet

# re: Oops! Typed Datasets ARE scalable!

Hi
I do not share your concern about the layers thing
If you give a closer look at the DNA diagram you will find
the Business Entity declaration.
Those Entities meant to be state-full and move through the tiers.
DataSet or Typed DataSet is one of the classic Business Entities.
You shouldn’t be worry about them if you dealing with smart client
and if you dealing with web client they always can be serialized to XML.

Any way I do not like the current implementation of Typed DataSet but
I do like their idea.
Friday, March 18, 2005 7:11 AM by TrackBack

# Sort/Filter Your Business Entity Collections with a NEW CollectionView

Tuesday, March 22, 2005 5:00 AM by TrackBack

# Sort/Filter Your Business Entity Collections with a NEW CollectionView

You’ve probably heard a lot of talk about why you should use Business Entities rather...
Thursday, June 15, 2006 2:32 AM by Ashish

# re: Oops! Typed Datasets ARE scalable!

Hi what is differnet beetween Typed Dataset and Component Class. As typed Dataset is .xsd file but one senior person using Component class means .cs file and saying that this is Typed Dataset

Thursday, June 29, 2006 9:39 AM by Davide Senatore

# re: Oops! Typed Datasets ARE scalable!

Hey, Roy! You are THE man! Your simple observation is very very clever! Share Schemas, not Classes!! Good work!