Click here to Skip to main content
Click here to Skip to main content

Create a Business Logic Layer, Data Access Layer classes, and Stored Procedure scripts from a database table

, 4 Jun 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Create a Business Logic Layer, Data Access Layer classes, and Stored Procedure scripts from a database table.

Introduction

One of the most tedious parts of developing database-driven applications is coding the classes for your database objects. Especially in a situation when you are dealing with a database containing a large number of tables, or tables with many columns. Today, the application development process has vastly expanded so it is better to use sub applications to generate code dynamically / automatically. I developed this application to reduce burden on software developers and provide them some relief. As a software developer, I can understand very well that programming is a tough job so they need some rest.

Key features

The application is designed to create:

  1. Business Logic Layer class
  2. Data Access Layer class
  3. SQL Database Stored Procedure script

Key benefits

  1. Reduce development time.
  2. Reduce development cost.
  3. Follow standard coding techniques and application architecture.
  4. Fully commented code so any one can easily modify it according to their needs.

How to use this application

In order to use this application, you must know the computer name/ IP address and the login information for connecting to a SQL Server database.

NotConnected.JPG

After successful login, you can go to another tab "Create Class and Stored Procedure". Select a particular database and check the tables to create the Stored Procedure and classes. Click on the Create button to create Stored Procedures and classes.

All classes and Stored Procedure scripts reside in the bin folder.

Connected.JPG

Example

As a very simple example, suppose we have the table name Employee.

DBTable.JPG

Create Business Logic Layer class

The Business Logic Layer class contains the namespaces, default constructor, private fields, and public properties with getters and setters and all the methods (Select, Insert, Delete, and Update) required for connecting the Database Access Layer. For every database table, it creates a class with the same name as the table name and concatenates it with controller. This example application will create a class with the name clsEmployeeController. It also creates properties with the name same as the table attributes.

BusinessLayer.JPG

Create Data Access Layer class

The Database Access Layer class contains the namespaces, default constructor, private fields, and public properties with getters and setters and all the methods (Select, Insert, Delete, and Update) required to directly deal with a database with Stored Procedures. For every database table, it creates a class with the same name as the table name and creates the properties with the same name as the table attributes. In this example, the application will create a class with the name clsEmployee.

DataBaseLayer.JPG

Create Stored Procedure script

It also creates a script of four Stored Procedures (Select, Insert, Delete, Update) in a Notepad file with the same name as the table name. You can simply copy and run it on the SQL Query Analyzer.

Points of Interest

I did not use any library in this application. It is a small application with big benefits.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Syeda Anila Nusrat
Software Developer
Pakistan Pakistan
Name: Syeda Anila Nusrat
 
Education:-
National University of Computer and Emerging Sciences
MS (Computer Science) 2010–2012
Federal Urdu University of Arts, Science and Technology
BS (Computer Science) 2004–2007
 
Professional Experience:-
Software Engineer at Systems Pvt Ltd (Nov 2010-Mar 2011)
Software Engineer at Syndustria Pvt Ltd (Jun2008-Feb2010)
Software Engineer(internee) at yEvolve Pvt Ltd (Feb2008-Apr 2008)
 
Specialties:-
IDE: Ms Visual Studio 2005 and 2008
Programming Languages: C++.NET, C#.NET, VB.NET, ADO.NET
Web Technologies: ASP.NET, AJAX, Html, CSS, Java Scripting
Databases: SQL Server 2000, SQL Server 2005
Programming Methodologies: Multithreading and DLLs
Scheduling and Modeling tools: Ms-Project 2000, MS Visio, Rational Rose
 
Honors and Awards:-
Received Merit Certificate for scoring 3.81 CGPA on scale of 4.0 in BS(CS)
 
My professional Network
http://pk.linkedin.com/in/syedaanila

Comments and Discussions

 
QuestionWhat does mean "Transaction"? Please help... PinmemberTavbi16-Jul-14 9:29 
QuestionVariable and Properties Writting PinmemberShafiqur Rahman, Banladesh24-Jun-14 3:44 
QuestionGreat JOb! Pinmemberrajeshmoorthy17-Feb-14 17:02 
QuestionWhere does it create the class? PinmemberAhmed Alaa El-Din19-Dec-13 9:35 
QuestionComment PinmemberVicky19313-Jun-13 18:34 
QuestionMicrosoft.ApplicationBlocks.Data PinmemberMember 223132122-Aug-12 23:49 
AnswerRe: Microsoft.ApplicationBlocks.Data Pinmemberaurinai17-Dec-12 6:15 
QuestionAny chance for a VB.NET version? PinmemberGroBeMaus10-Apr-12 10:42 
QuestionWhy are there two classes for each table? PinmemberOpethManiac12-Jan-12 4:53 
What is the purpose of having two different classes for the same table?
 
And what is this "cls" before the class name good for?
AnswerRe: Why are there two classes for each table? PinmemberGroBeMaus11-Apr-12 4:09 
GeneralMy vote of 4 Pinmembervanita tripathi17-Nov-11 19:35 
GeneralMy vote of 5 PinmemberMahesh Gholap3-Jun-11 21:44 
General[My vote of 1] Please tell me you used CodeDom PinmemberArgyle4Ever4-Jun-10 5:31 
GeneralRe: [My vote of 1] Please tell me you used CodeDom PinmemberSyeda Anila Nusrat4-Jun-10 8:07 
GeneralRe: [My vote of 1] Please tell me you used CodeDom PinmemberArgyle4Ever4-Jun-10 9:35 
GeneralRe: [My vote of 1] Please tell me you used CodeDom Pinmemberjosto221-Jul-10 6:35 
Generalcombine with asp.net MVC Pinmemberzhuqil3-Jun-10 19:40 
GeneralCode generation error [modified] Pinmemberipadilla3-Jun-10 10:32 
GeneralRe: Code generation error PinmemberSyeda Anila Nusrat3-Jun-10 14:44 
GeneralRe: Code generation error Pinmemberipadilla3-Jun-10 20:40 
GeneralRe: Code generation error PinmemberSyeda Anila Nusrat3-Jun-10 21:47 
GeneralRe: Code generation error [modified] Pinmemberipadilla3-Jun-10 22:57 
GeneralRe: Code generation error PinmemberSyeda Anila Nusrat4-Jun-10 4:31 
GeneralRe: Code generation error [modified] Pinmemberipadilla4-Jun-10 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 4 Jun 2010
Article Copyright 2010 by Syeda Anila Nusrat
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid