Web Services Software Factory Data Access Guidance Package - Blog Engine Data Access Layer Tutorial

Web Services Software Factory Data Access Guidance Package - Blog Engine Data Access Layer Tutorial

by David Hayden ( .NET C# SQL Server Development )

 

I have been chatting about the Web Services Software Factory and all the code generation and automation benefits it provides based on the Guidance Automation Toolkit and Extensions.

I thought I would show off this code generation and automation by displaying bits and pieces of the Data Access Guidance Package in the Web Services Software Factory, which is responsible for creating the data access layer for your web services. If what I show you has you intrigued, I recommend viewing the MSDN Architecture Webcast - Introducing the Web Service Software Factory.

I started off creating a simple database for a pretend blog engine. I stuck with 4 basic tables as shown:

 

Blog Engine Database

 

The Data Access Guidance Package in the Web Services Software Factory will create our business entities and our data access layer given just the tables in our database.

 

Create the Visual Studio Solution

Assuming you have everything installed ( Guidance Automation Extensions, Guidance Automation Toolkit, and Web Services Software Factory ), you can fire up Visual Studio and create the solution. Select the ASMX Service and let it build the appropriate projects.

 

Web Services Software Factory

 

Web Services Software Factory Solution

 

Web Services Software Factory Projects

 

 

Code Generation of CRUD Stored Procedures

Once I have the project set-up and have properly set my database connection, I can generate the CRUD Stored Procedures based on the tables in the "Blog" Database. A wizard walks you through the creation of a .SQL File that will create all the stored procedures that you requested based on the tables chosen in the database. In this case, I just had it create all the default stored procedures for my blog engine:

 

Generate CRUD Stored Procedures

 

Blog Engine Stored Procedures

 

 

Generate Business Entities from Database Tables

After creating the stored procedures, you can create the business entities based on the database tables. Once again, you just specify the databast tables and it automatically generates persistent ignorant entities based on those tables. You will have to create the relationships between those entities yourself. I manually added the CategoryCollection Class show below. The Web Services Software Factory does not create collection classes at this point.

 

Generate Business Entities

 

Generate Business Classes

 

 

Create Data Repository Classes From Business Entities

One you have your stored procedures and business entities generated, you can create your data repository classes from the business entities. You select your business entities and then map those business entities to stored procedures in the database.

 

Generate Repositories in Data Access Layer

 

 

Generate Data Access Layer - Code Generation

 

Conclusion

I will be talking about the code generated by the Data Access Guidance Package in the Web Services Software Factory in future posts. For now, enjoy the code generation capabilities in the Web Services Software Factory and the Guidance Automation Tookit and Extensions!

Written By: David Hayden ( .NET C# SQL Server Development )

Filed: Web Services Software Factory

 

posted on Saturday, September 23, 2006 6:13 PM

Main

News

Green Tea

.NET Development

Enterprise Library

Patterns & Practices