|By Bruce Armstrong||
|June 29, 2005 11:00 AM EDT||
In the early days of Java, a sample application called Java Pet Store was introduced as a "blueprint and guideline" for Java development. A few years later when Microsoft introduced .NET, they also provided a similar sample application to demonstrate preferred methods of coding for .NET called .NET Pet Shop. That has subsequently resulted in a bit of warfare as the two camps attempted to demonstrate why their implementation was a better, higher-performance implementation.
To provide a sample of using DataWindow.NET, I took a look at the .NET Pet Shop with an eye toward demonstrating how to use DataWindow Objects and DataStores in the data access layer. I won't claim that this particular implementation qualifies as a blueprint or guideline, or that it performs better than the original .NET implementation. What I do hope to show, however, is how easy and productive it is for you to use DataWindow.NET technology for database access.
Obtaining .NET Pet Shop
If you're going to walk through this with me, the first thing you'll have to do is get a copy of the .NET Pet Shop 3.0 from Microsoft at http://msdn.microsoft.com/library/en-us/dnbda/html/petshop3x.asp.
The installer for .NET Pet Shop will automatically create the necessary tables and other database objects in either Microsoft SQL Server or Oracle. One of the things we'll be looking at later is adding support for Sybase Adaptive Server Anywhere, but for the initial install you'll need one of those other two databases. There are evaluation copies of both available from their respective company's Web site.
The .NET Pet Shop Architecture
As the diagram from the .NET Pet Shop site indicates, this latest version of .NET Pet Shop has been abstracted into three tiers. The presentation tier is implemented in Web Forms that will run in your browser. That talks to a business-logic tier in the Web server, which in turn talks to a data access layer that is responsible for communicating with the database server. To support database portability, Microsoft included a data access layer (DAL) factory class that is responsible for determining which database vendor product it needs to talk to and then creates an appropriate DAL class specialized for that particular database.
That particular architecture suits our needs well. As we use DataWindow.NET technology to handle data access, we simply create additional DAL classes for that particular database - we don't have to touch any of the other code. (The source code for this article can be downloaded from www.pbdj.sys-con.com.)
Look Ma, No OLEDB!
One of the first things we'll do is examine the custom DAL class to determine what kind of operations we'll be implementing with DataWindow.NET components. One of the big surprises you'll encounter when you do that is that the custom DAL classes don't use any OleDbConnections. They also don't use any of the advanced data classes (DataAdapter, DataSet, DataTable) that you come to expect from an ADO.NET-based application. A clue this was coming was the database-specific DAL classes, as the advanced data classes were meant to provide a level of abstraction that was supposed to make database access uniform across providers. Therefore an implementation using those advanced classes would have not required database vendor-specific DAL classes.
The reason those advanced data classes weren't used is explained on the .NET Pet Shop site in a section entitled "Database Portability." Because they were concerned about performance, they elected to use each of the individual vendor's .NET managed providers. They indicate that the .NET-managed providers are two to three time faster than the OLEDB provider.
What it also means, besides having to provide a custom DAL class for each database vendor, is that the custom DAL classes are also full of embedded SQL. Take a look, for example, at the Account.cs class for one of the custom DAL classes and you'll find quite a number of public constant declarations that look something like Listing 1.
|Tanveer 08/29/05 11:12:27 PM EDT|
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- Creation and Consumption of Web Services with PowerBuilder
- Cloud People: A Who's Who of Cloud Computing
- DDDW Tips and Tricks
- Cloud Expo 2011 East To Attract 10,000 Delegates and 200 Exhibitors
- Working with SOA & Web Services in PowerBuilder
- Dynamically Creating DataWindow Objects
- Cloud Expo, Inc. Announces Cloud Expo 2011 New York Venue
- OLE - Extending the Capabilities of PowerBuilder