2.3. Creating a Strongly Typed DataSet
Problem
You want to create a strongly typed object wrapper around a
DataSet.
Solution
Use one of the three techniques shown in the discussion to create a
strongly typed DataSet using either the Visual
Studio .NET IDE or a command line approach.
Discussion
A strongly typed DataSet is a collection of
classes that inherit from and extend the DataSet,
DataTable, and DataRow classes,
and provide additional properties, methods, and events based on the
DataSet schema. You can use all of the
functionality in classes from which the strongly typed classes
inherit in the same way as with untyped classes.
A strongly typed DataSet class contains, in
addition to a single class extending the DataSet
class, three classes for each table in the DataSet
extending each of the DataTable,
DataRow, and DataRowChangeEvent
classes. This recipe describes these classes and discusses their
commonly used methods and properties.
There is a class named
TableNameDataTable for
each table in the strongly typed DataSet. It has
the base class DataTable. Table 2-1 lists commonly used methods of this class
specific to the strongly typed DataSet.
Table 2-1. TableNameDataTable methods
|
Method |
Description |
|---|---|
|
|
Adds a row to the table. The method has two overloads: one takes a
|
|
|
Takes |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access