Scott on Writing

Musings on technical writing...

Thursday, June 22, 2006 #

The Namespace and Class Names for Strongly Typed DataSets and TableAdapters

In my multi-part tutorial series on Working with Data in ASP.NET 2.0, the tutorials are built upon an application architecture that uses a Typed DataSet as the Data Access Layer (DAL) and custom classes for the Business Logic Layer (BLL). In the first tutorial, the DAL is created, resulting in the following business objects:

  • Northwind - the strongly-typed DataSet that has the set of strongly-typed DataTables and the relationships among them
  • Northwind.ProductsDataTable - a strongly-typed DataTable that provides information about a set of products
  • Northwind.ProductsRow - a strongly-typed DataRow that provides information about a particular product instance; has properties like ProductID, ProductName, UnitPrice, and so on.

There are other business object classes that model the other tables in the database - Northwind.CategoriesDataTable, Northwind.CategoriesRow, and so on.

In addition to these business objects, the Typed DataSet includes TableAdapters, which provide the methods for populating these business objects with data from the database (as well as methods for inserting, updating, and deleting data). The TableAdapter classes automatically created by the Typed DataSet include one for each DataTable, and are found in the NorthwindTableAdapters namespace. These classes include:

  • ProductsTableAdapter
  • CategoriesTableAdapter
  • SuppliersTableAdapter
  • EmployeesTableAdapter

A question I've received from a number of folks who've read the tutorials is, “How do I change the names of these classes?” The names for the Typed DataSet, its DataTables and DataRows, and the TableAdpaters and their namespace are all determined by properties for these objects. By default, the name for the DataSet is the name of the DataSet file in your project. For the tutorial, I named the DataSet file Northwind.xsd, hence the Typed DataSet name is Northwind.

If you don't want to use the name of the DataSet file as the Typed DataSet name, you can change it by opening the DataSet in the Designer view, going to the Properties window, and changing the Name setting from Northwind (or whatever) to the name you desire. Imagine that you wanted to change the name to Scott, in an attempt to pump up my already overinflated ego. After doing so (and saving the DataSet file), the class names would change to:

  • Scott
  • Scott.ProductsDataTable
  • Scott.ProductsRow
  • ...

And the TableAdapters would all be in the ScottTableAdapters namespace. Similarly, to change the name of a DataTable or TableAdapter, click on the DataTable or TableAdapter in the DataSet Designer, go to the Properties window, and change the Name property. That's all there is to it!

Happy Programming!

posted @ 7:34 AM | Feedback (6)

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<June 2006>
SMTWTFS
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

Comment Stats

DayTotal% of Total
Sunday 1896.8%
Monday 39014.0%
Tuesday 46916.8%
Wednesday 51518.5%
Thursday 54419.5%
Friday 50818.2%
Saturday 1706.1%
Total 2785100.0%

Hour1Total% of Total
12:00 AM 682.4%
1:00 AM 712.5%
2:00 AM 632.3%
3:00 AM 752.7%
4:00 AM 572.0%
5:00 AM 1093.9%
6:00 AM 1114.0%
7:00 AM 1615.8%
8:00 AM 1756.3%
9:00 AM 1505.4%
10:00 AM 1736.2%
11:00 AM 1826.5%
12:00 PM 1906.8%
1:00 PM 1766.3%
2:00 PM 1605.7%
3:00 PM 1324.7%
4:00 PM 1124.0%
5:00 PM 983.5%
6:00 PM 913.3%
7:00 PM 993.6%
8:00 PM 853.1%
9:00 PM 802.9%
10:00 PM 833.0%
11:00 PM 843.0%
Total 2785100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.14144
Monday 5.35353
Tuesday 4.35444
Wednesday 7.58644
Thursday 6.87625
Friday 5.45414
Saturday 5.03161
Total 5.802785

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.45109
9:00 AM 6.34279
10:00 AM 6.41250
11:00 AM 4.28184
12:00 PM 6.98342
1:00 PM 2.87112
2:00 PM 5.29222
3:00 PM 8.54299
4:00 PM 3.9190
5:00 PM 5.78156
6:00 PM 4.52113
7:00 PM 9.32177
8:00 PM 9.06154
9:00 PM 5.14113
10:00 PM 6.2381
11:00 PM 4.5732
Total 5.802785

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles