Creating Typed Data Sets with Command Line Tools

One other way to create typed data set definitions may make sense for some situations, but it means giving up some of the best features described so far. The command line tool XML Schema Support utility (xsd.exe) that comes with the .NET Framework SDK does a number of things, one of which is to let you run it against an XML Schema definition and generate a typed data set class definition from that schema. There are a number of limitations as to the shape of the schema providedbasically it has to be a schema that can be flattened into a relational schema within the data set definition that is generated.

The big limitation with the typed data set definition this tool generates is that the definition is just the data set definition itselfit doesn't have any associated table adapters. Because you are working from the command line, there is no direct tie to a database and its schema, and it would reguire a complicated syntax to include all the information that you easily specify through drag-and-drop and wizard operations in Visual Studio. You will also have to get the XML schema you are basing it on from somewhere; there is no autogeneration of the schema based on a database as in the Visual Studio environment.

Even with its limitations, this is still a useful tool to be aware of: There may be times you'll be building distributed applications that pass around data sets and you may not have direct access to the database that those data sets are going to be populated from. Or you may be specifically using typed data sets as simple but powerful business data entity definitions that are decoupled from the database schema by design. As long as someone can provide you with a schema that describes what the data sets will look like that you'll be working withor you can define one yourselfyou can easily generate a strongly typed data set class with xsd.exe for working with that data. The tool also supports other capabilities, such as the conversion of XML Data Reduced (XDR) schemas to XML Schema Definition (XSD) schemas, as well as the generation of classes from a schema that are simple data transfer classes that aren't related to data sets.

4 PREY

0 0

Post a comment