Free mag vol1 | Page 962

CHAPTER 22  ADO.NET PART II: THE DISCONNECTED LAYER The autogenerated data adapter object (which you will learn more about momentarily) uses the lengthy value, "DataGridViewDataDesigner.Properties.Settings.AutoLotConnectionString". Examining the Strongly Typed DataSet In addition to your configuration file, the data wizard tools generated what is termed a strongly typed DataSet. This term describes a custom class that extends DataSet and exposes a number of members that allow you to interact with the database using a more intuitive object model. For example, strongly typed DataSet objects contain properties that map directly to the database tables names. Thus, you can use the Inventory property to nab the rows and columns directly, rather than having to drill into the collection of tables using the Tables property. If you insert a new class diagram file into your project (by selecting the project icon in Solution Explorer and clicking the View Class Diagram button), you’ll notice that the wizard has created a class named InventoryDataSet. This class defines a handful of members, the most important of which is a property named Inventory (see Figure 22-20). Figure 22-20. The Data Source Configuration Wizard created a strongly typed DataSet If you double-click the InventoryDataSet.xsd file within Solution Explorer, you will load the Visual Studio Dataset Designer (you’ll learn more details about this designer momentarily). If you right-click anywhere within this designer and select the View Code option, you will notice the following fairly empty partial class definition: public partial class InventoryDataSet { } If necessary, you can add custom members to this partial class definition; however, the real action takes place within the designer-maintained file, InventoryDataSet.Designer.cs. If you open this file using Solution Explorer, you will see that InventoryDataSet extends the DataSet parent class. Consider the following partial code, with comments added for clarity: // This is all designer-generated code! public partial class InventoryDataSet : global::System.Data.DataSet { // A member variable of type InventoryDataTable. 908